Problem with module loading outside main.lua folder

Hello, In my project I have a folder called libs and a subfolder called mylib within a subfolder called orm. Inside this folder ‘orm’ there is a lua module called example. In this module ‘example’ there is an import to other module named otherexample which is located in a sub folder from module ‘example’, e.g:

…main.lua

… … / libs

… … / libs / mylib

… … / libs / mylib / orm

… … / libs / mylib / orm / example.lua

… … / libs / mylib / orm / subfolder / otherexample.lua

If I try to import it on my main.lua as:

local thisisalib = require(“libs.mylib.orm.example”) 

I get a error on example module saying it cannot found module otherexample.lua. In example.lua it is required as:

local otherexamplelib = require(“subfolder.otherexample”)

In my main.lua I tried to add to package.path like:

package.path = package.path … ‘libs/mylib/orm/subfolder/?.lua’

 

but still getting error. Any ideas?

You must use the full path relative to root (folder where main.lua is) for all require calls.
 
i.e. To require “otherexample.lua” is always:

local otherexamplelib =  require( "libs.mylib.orm.otherexample" ) 

i.e. Even if you require ‘otherexample.lua’ from ‘example.lua’ you must use the full path.

You must use the full path relative to root (folder where main.lua is) for all require calls.
 
i.e. To require “otherexample.lua” is always:

local otherexamplelib =  require( "libs.mylib.orm.otherexample" ) 

i.e. Even if you require ‘otherexample.lua’ from ‘example.lua’ you must use the full path.