如果找不到pm2
可以先通过下面命令安装
# yarn pm2 install
yarn global add pm2 --prefix /usr/local
# npm pm2 install
npm install pm2 -g
报错信息入下
[PM2][ERROR] Script not found
解决
在项目根目录下添加配置文件 ecosystem.config.js
,再执行nuxt build
或yarn build
module.exports = {
apps: [
{
name: 'NuxtAppName', // 应用名称,不多解释
exec_mode: 'cluster', // 默认为fork
instances: 'max', // Or a number of instances ,这里可以根据机器配置自行修改i
script: './node_modules/nuxt/bin/nuxt.js',
args: 'start'
}
]
}
启动
pm2 start
查看是否启动成功
pm2 ls