I'm having an issue using pm2 with ts-node for deployment.
Whenever I try to use cluster-mode
, a pm2 instance error occurs, saying "Cannot find module..."
Error: Cannot find module '{path}/start'
at main ({path}/node_modules/ts-node/dist/bin.js:178:20)
at Object. ({path}/node_modules/ts-node/dist/bin.js:404:5)
Here is my ecosystem.config.js and
"production": "pm2-runtime start ecosystem.config.js --env production"
this is my package script.
module.exports = {
apps: [
{
script: "ts-node",
args: "./server.ts",
instances: "max",
exec_mode: 'cluster_mode',
node_args: '-r esm'
env_production: {...}
}
]
}
However, when I switch to fork-mode
instead of cluster-mode
, the app functions correctly.
I'm currently stuck on how to resolve this problem.
If you have any ideas or solutions, please let me know.