This is my first nodejs app and when I try to run the app using PM2 then app start and immediately it’s become to errored and pm2 logs showing this
/root/.pm2/logs/app-out.log last 15 lines:
/root/.pm2/logs/app-error.log last 15 lines:
1|app | at Module.load (module.js:565:32)
1|app | at tryModuleLoad (module.js:505:12)
1|app | at Function.Module._load (module.js:497:3)
1|app | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerForkLegacy.js:28:21) code: 'MODULE_NOT_FOUND' }
1|app | { Error: Cannot find module 'express'
1|app | at Function.Module._resolveFilename (module.js:547:15)
1|app | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:61:29)
1|app | at require (internal/module.js:11:18)
1|app | at Object.<anonymous> (/var/www/whatsclone/app.js:18:17)
1|app | at Module._compile (module.js:652:30)
1|app | at Object.Module._extensions..js (module.js:663:10)
1|app | at Module.load (module.js:565:32)
1|app | at tryModuleLoad (module.js:505:12)
1|app | at Function.Module._load (module.js:497:3)
1|app | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerForkLegacy.js:28:21) code: 'MODULE_NOT_FOUND' }
I have tried sudo pm2 update
| npm install
| npm install express
Nothing fixed for me. Please help me
node -v
v8.10.0
npm -v
3.5.2
Thanks
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
Are you running these commands in your project folder? It might be that these are not installed globally. Run this in your project folder:
And also make sure you run your app from the project folder. Let me know if this works or got any more questions.