Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How do I deploy an SSR NuxtJs app to a host

I'm coming from the SPA / React world and am working on my first Nuxtjs SSR app.

When I run an npm run build I'm expecting artifacts to be created which can be copied over to my production environment that are then run using node on the server. When I do an npm run build, I get nothing in a dist folder but in ./nuxt/dist there are two folders, server and client.

Completely lost on how to proceed from there. All the online help seems to be for non production builds with the entire development folder present to run nuxt start.

How do I do a production deployment and run it using node on a server

like image 572
nova Avatar asked Nov 07 '22 05:11


1 Answers

There are several way to publish nuxt:

So, for an SPA deployment, you must do the following: Change mode in nuxt.config.js to spa. Run npm run build. Deploy the created dist/ folder to your static hosting like Surge, GitHub Pages or nginx.

but I think you use universal mode (SSR) so in this mode its better to install npm or yarn in server and run this command in your production server

nuxt build
nuxt start

So if you want to copy dist folder change mode of project to SPA in nuxt.config.js

For more information read this article

How do I deploy an SSR NuxtJs app to a host

like image 191
soroush Avatar answered Nov 12 '22 12:11