By Rusith
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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Are you running these commands in your project folder? It might be that these are not installed globally. Run this in your project folder:
npm install express --save
And also make sure you run your app from the project folder. Let me know if this works or got any more questions.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.