简体   繁体   English

命令“yarn run start”的“PM2”是什么?

[英]What is the `PM2` for command `yarn run start`?

I run the nodejs app with yarn run start , what is the command for pm2 I should use?我使用yarn run start运行 nodejs 应用程序,我应该使用 pm2 的命令是什么?

pm2 yarn run start give me an error. pm2 yarn run start给我一个错误。

My package.json content我的package.json内容

"scripts": {
    "start": "budo main.js:dist/bundle.js --live --host 0.0.0.0",
    "watch": "watchify main.js -v --debug -o dist/bundle.js",
    "prep": "yarn && mkdirp dist",
    "build": "browserify main.js -o dist/bundle.js",
    "lint": "eslint main.js --fix",
    "deploy": "yarn build && uglifyjs dist/bundle.js -c -m -o dist/bundle.min.js"
  },

For me (on ubuntu 20)对我来说(在 ubuntu 20 上)

pm2 start yarn --name api -- start

would do the trick.会成功的。 With the bash interpreter flag it would error in pm2.使用 bash 解释器标志,它会在 pm2 中出错。

The error you're getting is because a bash script (yarn) is being executed with node...您收到的错误是因为正在使用节点执行 bash 脚本(纱线)...

Because pm2's default interpreter is set to node.因为 pm2 的默认解释器设置为 node。

To run yarn you'll have to set the interpreter to bash:要运行 yarn,您必须将解释器设置为 bash:

shell:壳:

Try the command below:试试下面的命令:

pm2 start yarn --interpreter bash --name api -- start
pm2 start yarn --name api -- start

Won't work for me.不会为我工作。

It displays below它显示在下面

0|api      | /usr/share/yarn/bin/yarn:2
0|api      | argv0=$(echo "$0" | sed -e 's,\\,/,g')
0|api      | SyntaxError: missing ) after argument list

It means launching a yarn binary file with a node.js这意味着使用 node.js 启动一个 yarn 二进制文件

How about this command.这个命令怎么样。

pm2 start "yarn start" --name api

It work's like charm for me.它对我来说就像魅力一样。

我的 pm2 版本是5.2.0

pm2 start "yarn start" --name yourProjec

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM