当我独立启动我的应用程序时没有问题,但为了简化托管,我希望
pm2
使用 ecosystem.config.js
文件启动它们。
这是我的
ecosystem.config.js
:
module.exports = {
apps: [
{
name: "strapi_portfolio",
cwd: "./server",
script: "npm",
args: "start",
exec_mode: "fork",
exec_interpreter: "bash",
exec_args: "-c 'npm run build && npm start' ",
autorestart: true,
},
{
name: "nextjs_portfolio",
cwd: "./client",
script: "npm",
args: "start",
exec_mode: "fork",
exec_interpreter: "bash",
exec_args: "-c 'npm run build && npm start' ",
autorestart: true,
wait_ready: true,
listen_timeout: 60000,
},
],
};
但是当我执行
pm2 start
命令时,我得到这个错误(它对 strapi_portfolio 和 nextjs_portfolio 都有):
0|strapi_p | /root/.nvm/versions/node/v18.15.0/bin/npm: line 2: require('../lib/cli.js')(process)' 0|strapi_p | /root/.nvm/versions/node/v18.15.0/bin/npm: line 2: syntax error near unexpected token '../lib/cli.js'
我正在使用
nvm
来管理我服务器上的节点版本。
您是否知道可能导致此错误的原因? 提前致谢!