I want to start a process using PM2, but it doesn't seem to pick up node arguments relative to the current working directory.
Running this from /path/to/dir/
works:
pm2 start dist/main.js --node-args="-r ./tsconfig-paths-bootstrap.js" -- -c config.json
whereas using this ecosystem file:
{
"apps": [
{
"name": "server",
"script": "dist/main.js",
"instances": 2,
"exec_mode": "cluster",
"cwd": "/path/to/dir/",
"args": [
"-c",
"config.json"
],
"node_args": [
"-r",
"./tsconfig-paths-bootstrap.js"
],
"watch": false
}
]
}
and running: pm2 start server
gives me the following error: Error: Cannot find module './tsconfig-paths-bootstrap.js'
How can this be fixed?
Try this:
"node_args": ["-r ./tsconfig-paths-bootstrap.js"]
And make sure your file is in same directory else you need to give full p ath to file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.