In my situation, I also met pm2 errored
:
internal/modules/cjs/loader.js:1068
throw err;
^
Error: Cannot find module './config'
Require stack:
- /usr/my/express/js/app.js
- /usr/my/express/js/bin/www
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1065:15)
at Function.Module._load (internal/modules/cjs/loader.js:911:27)
at Module.require (internal/modules/cjs/loader.js:1125:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/usr/my/express/js/app.js:9:16)
at Module._compile (internal/modules/cjs/loader.js:1236:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
at Module.load (internal/modules/cjs/loader.js:1085:32)
at Function.Module._load (internal/modules/cjs/loader.js:950:14)
at Module.require (internal/modules/cjs/loader.js:1125:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/my/express/js/app.js',
'/usr/my/express/js/bin/www'
]
}
[nodemon] app crashed - waiting for file changes before starting...
As you can see above, I lost my ./config
file, because I added it into .gitignore
and when I cloned it on local machine, it lost.
Just retrieve the file back, and the problem solved!