[英]Unable to run pm2 with npx babel?
I have a Node.js app that perfectly works with the following command:我有一个 Node.js 应用程序,它可以完美地与以下命令配合使用:
npx babel-node dist/index.js
However, I'm not able to run this with pm2.但是,我无法使用 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
.这也不起作用,因为我的全局 babel 是版本
6.26.3
而我的项目 babel 是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
?有没有办法让 pm2 与 npx 一起玩得很好,或者也许有办法将系统范围的 babel 升级到
7.0
?
To solve this you need to create a build
and a start
script in your package.json
:要解决这个问题,您需要在
package.json
创建一个build
和一个start
脚本:
"scripts": {
"build": "npx babel src -d dist",
"start": "npm run build && node dist/index.js"
},
And then run the pm2 using the start option:然后使用 start 选项运行 pm2:
pm2 start npm --name "app name" -- start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.