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.
require stackerror typically means one of the file paths for aconst 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/…ecosystem.config.jsfile and at least thescriptssection of yourpackage.jsonfile. Tell us what kind of system you're using for a host. Maybe we can make some better guesses about what is wrong.