2

I am using WinSCP and Nginx to host my application but I keep on getting this error when I check the logs of pm2 I checked my WinSCP and it says it contains all folders so it doesn't seem to have anything missing

/home/***/.pm2/logs/server-error.log last 15 lines:
0|server   | Require stack:
0|server   | - /home/***/server.js
0|server   |     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
0|server   |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:61:29)
0|server   |     at require (internal/modules/cjs/helpers.js:88:18)
0|server   |     at Object.<anonymous> (/home/*****/server.js:8:22)
0|server   |     at Module._compile (internal/modules/cjs/loader.js:1063:30)
0|server   |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|server   |     at Module.load (internal/modules/cjs/loader.js:928:32)
0|server   |     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
0|server   |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|server   |     at Module._compile (internal/modules/cjs/loader.js:1063:30) {
0|server   |   code: 'MODULE_NOT_FOUND',
0|server   |   requireStack: [ '/home/****/server.js' ]
0|server   | }

I am unsure of what the "require stack" error means and I am unsure of how to handle it. Can someone point me in the right direction? If you need more information please let me know.

3
  • 1
    A require stack error typically means one of the file paths for a const foo = require('../foo') is not written correctly for the use case. What do the imports in your /home/****/server.js look like? And what is the script pm2 is running? These affect where your node process is running and what your relative paths in require statements will be using. Maybe related to this: stackoverflow.com/questions/19272880/… Commented Jan 19, 2021 at 14:26
  • The script pm2 runnning is server.js which is in the ecosytem.config.js I have deployed this app before using something else so I know its something that is just going over my head . I will check the relative paths too Thanks. Commented Jan 19, 2021 at 14:54
  • Please edit your question to show us your ecosystem.config.js file and at least the scripts section of your package.json file. Tell us what kind of system you're using for a host. Maybe we can make some better guesses about what is wrong. Commented Jan 27, 2021 at 11:42

1 Answer 1

0

It's a stack trace. Your underlying error is an attempt to require() a module that doesn't exist.

Node's stack traces for require() failures are notorious for their uselessness. Ignore them. Just figure out which module is missing, and fix it.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, I really need help with pm2. So i did everything as every tutorial suggests. my pm2 status is active and online, i also did the pm2 startup part but still my app is not working. When i stop pm2 and run node index.js my app works. Why is pm2 not working?
@kd12345 Did you manage to solve it? I have a similar error :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.