gpt4 book ai didi

node.js - pm2下如何运行nuxt?

转载 作者:搜寻专家 更新时间:2023-10-31 22:40:28 24 4
gpt4 key购买 nike

我有 2 个 nuxt 项目需要在服务器上运行。每当我在本地运行应用程序时,它似乎都在使用:npm run dev,但在服务器上,这需要在子进程下运行,所以我为此使用 pm2。但是每当我开始使用 pm2 运行相同的 npm 脚本时,过程就会出错。

用于此的命令是:sudo pm2 start npm --name "dev"-- dev,即使我单独运行应用程序也会出错。 sudo pm2 start npm --name "app1"-- app1:devsudo pm2 start npm --name "app2"-- app2:dev


package.json

{
...
"scripts": {
"app1:dev": "nuxt --config-file src/app1/nuxt.config.js -p=3000",
"app2:dev": "nuxt --config-file src/app2/nuxt.config.js -p=4000",
"dev": "concurrently \"npm run app1:dev\" \"npm run app2:dev\"",
},
"dependencies": {
...
},
"devDependencies": {
"concurrently": "^3.6.0",
"cross-env": "^5.2.0"
}
}


pm2 日志

/home/ubuntu/.pm2/pm2.log :
PM2 | [2018-08-16T10:05:55.046Z] PM2 log: ===============================================================================
...
PM2 | [2018-08-16T10:07:32.825Z] PM2 log: App [app1] with id [0] and pid [11135], exited with code [1] via signal [SIGINT]
PM2 | [2018-08-16T10:07:32.827Z] PM2 log: Starting execution sequence in -fork mode- for app name:app1 id:0
PM2 | [2018-08-16T10:07:32.828Z] PM2 log: App name:app1 id:0 online
PM2 | [2018-08-16T10:07:33.105Z] PM2 log: App [app1] with id [0] and pid [11145], exited with code [1] via signal [SIGINT]
PM2 | [2018-08-16T10:07:33.106Z] PM2 log: Starting execution sequence in -fork mode- for app name:app1 id:0
PM2 | [2018-08-16T10:07:33.108Z] PM2 log: App name:app1 id:0 online
PM2 | [2018-08-16T10:07:33.383Z] PM2 log: App [app1] with id [0] and pid [11155], exited with code [1] via signal [SIGINT]
PM2 | [2018-08-16T10:07:33.383Z] PM2 log: Script /usr/local/bin/npm had too many unstable restarts (16). Stopped. "errored"

/home/ubuntu/.pm2/logs/app1-error.log :
/home/ubuntu/.pm2/logs/app1-out.log :
...
0|app1 | Specify configs in the ini-formatted file:
0|app1 | /home/ubuntu/.npmrc
0|app1 | or on the command line via: npm <command> --key value
0|app1 | Config info can be viewed via: npm help config
0|app1 |
0|app1 | npm@5.6.0 /usr/local/lib/node_modules/npm
0|app1 |
0|app1 | Usage: npm <command>
0|app1 |
0|app1 | where <command> is one of:
0|app1 | access, adduser, bin, bugs, c, cache, completion, config,
0|app1 | ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
0|app1 | explore, get, help, help-search, i, init, install,
0|app1 | install-test, it, link, list, ln, login, logout, ls,
0|app1 | outdated, owner, pack, ping, prefix, profile, prune,
0|app1 | publish, rb, rebuild, repo, restart, root, run, run-script,
0|app1 | s, se, search, set, shrinkwrap, star, stars, start, stop, t,
0|app1 | team, test, token, tst, un, uninstall, unpublish, unstar,
0|app1 | up, update, v, version, view, whoami
0|app1 |
0|app1 | npm <command> -h quick help on <command>
0|app1 | npm -l display full usage info
0|app1 | npm help <term> search for help on <term>
0|app1 | npm help npm involved overview
0|app1 |
...

这一切意味着什么,pm2 不识别 npm 命令吗?我在这里缺少参数吗? ...

额外信息:
服务器:Ubuntu 16.04
npm 版本:5.6.0
nuxt 版本:1.4.2
pm2版本:3.0.3
Node 版本:8.11.1

最佳答案

下面的代码:

pm2 start npm --name "anyName" -- run dev

关于node.js - pm2下如何运行nuxt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51875055/

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