Cannot use require in nested folders

I’m using cocos IDE.

When I require some lua module from a file residing in the /src folder it works, but when the file using require is inside a subfolder of src it fails.

Lets say I have these files:
/src/main.lua /src/lib/a.lua /src/lib/b.lua

Using require "lib.a" in main.lua works, but not from inside b.lua.

but not from inside b.lua
–I don’t catch this sentence.

In an empty project have the following files:

  • /src/lib/a.lua

return function() print "hello" end

  • /src/main.lua

local f = require "lib.a" -- this works as expected

  • /src/lib/b.lua

local f = require "lib.a" -- this fails