love.js icon indicating copy to clipboard operation
love.js copied to clipboard

[BUG] Cannot import file with same name as game's parent folder

Open ChicknTurtle opened this issue 1 year ago • 1 comments

This issue only occurs when using love.js. I have a game, with a filetree like this:

game/
├── main.lua
└── game.lua

When I attempt to import game.lua from main.lua...

Game = require 'game'

I get the error:

Error: main.lua:1: module 'game' not found:
love.js:9 	no field package.preload['game']
love.js:9 	no 'game' in LOVE game directories.
love.js:9 	no file 'game' in LOVE paths.
...

However, when I rename my game folder to something else (like src), it works fine. Took me forever to figure this out, now it's not much of a problem for me.

Here is how I packaged my game:

love.js game .packaged -t game -c

ChicknTurtle avatar May 17 '24 21:05 ChicknTurtle

@Davidobot

DocNITE avatar Jun 01 '24 22:06 DocNITE