gpt4 book ai didi

node.js - PM2如何运行 "npm start"?

转载 作者:搜寻专家 更新时间:2023-11-01 00:27:49 24 4
gpt4 key购买 nike

我在这里看到了很多问题,但这对我不起作用。那为什么要问这个问题?

我正在使用 DigitalOcean Ubuntu 16.04 服务器。我有一个由“npm start”运行的 Node 项目。

脚本是:

"scripts": {    
"start": "node ./bin/www"
}

一般pm2适用于

pm2 start app.js

因为我的脚本是这样的,并且由 npm start 运行,我怎样才能永远运行我的服务器。

最佳答案

你可以像这样运行内置的 npm 脚本:

pm2 start npm -- start

如果你有自定义脚本,你可以这样运行:

pm2 start npm -- run custom

--

在您的情况下,pm2 start npm -- start 将运行 node ./bin/www。如果要运行 node app.js,请将 start 脚本更改为 node app.js

关于node.js - PM2如何运行 "npm start"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52575208/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com