its comming in ubuntu.. getting this error while hosted website. after checking the docker container logs iam able to see this error. but its running in local device..

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../repositories/UserRepository'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/app/usr/src/services/user.services.js:2:24)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[nodemon] app crashed - waiting for file changes before starting.

iam getting this error when i check the container logs.please help me with this.. i tried some answers like npm install,apt-get update but all are not useful to me..

1

There are 1 best solutions below

0
Amir Almian On

create an alias with module-alias like this

moduleAlias.addAliases({
  '@app': __dirname,
});

and import this file from the alias like this

require('@app/path_to_directory/repositories/UserRepository)