Search code examples
node.jsnginxmongoosepm2

Require Stack / MODULE_NOT_FOUND error when running sudo pm2 start server.js


I'm new to NGINX. I am trying to run my Node server with sudo pm2 start server.js but I keep on getting MODULE_NOT_FOUND requireStack error. Everything's fine when I run it to a local machine but when I run on nginx, this keeps happening. I can't connect to my backend. Please, help.

enter image description here

I'm not sure if this will help, but when I also run node server.js, I also get this error.

enter image description here


Solution

  • Solved! I uninstalled mongoose npm uninstall mongoose and re-installed it npm install mongoose.