I have a Node.js app that perfectly works with the following command:
npx babel-node dist/index.js
However, I'm not able to run this with pm2. When I do the following:
pm2 start --interpreter npx babel-node dist/index.js
Obviously, this does not work. And when I try:
pm2 start --interpreter babel-node dist/index.js
This does not work either, as my global babel is version 6.26.3
and my project babel is 7.0.0-0
.
Is there a way to make pm2 to play nice with npx or maybe there is a way to upgrade the system wide babel to 7.0
?
To solve this you need to create a build
and a start
script in your package.json
:
"scripts": {
"build": "npx babel src -d dist",
"start": "npm run build && node dist/index.js"
},
And then run the pm2 using the start option:
pm2 start npm --name "app name" -- start
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.