Nuxt/docs/content/3.docs/8.deployment/5.pm2.md

59 lines
1.2 KiB
Markdown
Raw Normal View History

---
icon: LogoPM2
---
# PM2
How to deploy Nuxt to a Node.js hosting using PM2.
::list
- Support for ultra-minimal SSR build
- Zero millisecond cold start
- More configuration required
::
## Setup
Make sure another preset isn't set in `nuxt.config`.
```js [nuxt.config.js|ts]
export default {
nitro: {
// this is the default preset so you can also just omit it entirely
// preset: 'server'
}
}
```
## Deployment
2021-11-21 12:31:44 +00:00
After running `yarn build`, all the required files are located in the `.output` folder. Static assets are in the `public` subdirectory and the server with its dependencies are within the `server` subdirectory.
2022-01-05 18:08:26 +00:00
This `.output` folder can be deployed to your Node.js host and the server can be run using [`pm2`](https://pm2.keymetrics.io/docs/usage/quick-start/).
To start the server in production mode, run:
```bash
node .output/server/index.mjs
```
For example, using `pm2`:
```js [ecosystem.config.js]
module.exports = {
apps: [
{
name: 'NuxtAppName',
exec_mode: 'cluster',
instances: 'max',
2021-11-05 15:37:32 +00:00
script: './.output/server/index.mjs'
}
]
}
```
## More information
2021-10-13 13:13:37 +00:00
See more information on the [server preset](/docs/deployment/presets/server).