Start nuxt project in PM2 daemon mode

Time:2022-6-11

1. Modify package json

{
  "name": "ii222",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt build && nuxt start",
    "generate": "nuxt generate"
  },
 //Omitted below
}

2 enter the project directory and execute the following commands

pm2 start ./node_modules/nuxt/bin/nuxt.js

Common PM2 commands

PM2 list \\list all applications started by PM2
PM2 stop 0 \\stop the specified application with ID 0
PM2 restart 0 \\n restart the application with ID 0
PM2 delete 0 \\delete the specified application ID 0



pm2 start app. JS \start app JS application
pm2 start app. JS --name= "demo" \
pm2 start app. JS --watch \
pm2 start script. SH \
PM2 show [app name] \
PM2 logs \
PM2 logs [app name] \
PM2 stop all \
PM2 restart all \\
PM2 delete all \
PM2 startup \
PM2 save \\save the current application list

PS: it is found that the first screen load is very slow after the above method is started, which may be the development mode. If you want to start the production mode, you can refer to this article:https://segmentfault.com/a/11…