Nuxt.js: pm2 run nuxt

Created on 15 Dec 2016  路  3Comments  路  Source: nuxt/nuxt.js

Hi, how can I run nuxt with PM2? Tried starting ./nuxt/index.js or ./nuxt/server.js but failed with errors.
I'm new with node servers.

This question is available on Nuxt.js community (#c51)
question

Most helpful comment

# for development
pm2 start npm --name "nuxt" -- run dev

# for production
npm run build
pm2 start npm --name "nuxt" -- start

All 3 comments

Hi,
To use npm commands with PM2, it seems that you need to create a config file:
ecosystem.config.js

module.exports = {
  apps : [
    {
      name: "nuxt-dev",
      script: "npm",
      args: "run dev"
    },
    {
      name: "nuxt-prod",
      script: "npm",
      args: "run start"
    }
  ]
}

then for development mode:

pm2 start ecosystem.config.js --only nuxt-dev

or for production mode:

npm run build && pm2 start ecosystem.config.js --only nuxt-prod
# for development
pm2 start npm --name "nuxt" -- run dev

# for production
npm run build
pm2 start npm --name "nuxt" -- start

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lazycrazy picture lazycrazy  路  3Comments

maicong picture maicong  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

vadimsg picture vadimsg  路  3Comments

bimohxh picture bimohxh  路  3Comments