6

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

nova
  • 165
  • 3
  • 10

2 Answers2

1

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

soroush
  • 742
  • 6
  • 10
  • I'm trying to get it to run in SSR mode, to use nuxt start I'd need to copy the entire folder I presume, not a compiled distribution? The ./nuxt/dist folder has two subfolders client server Should both be copied to the server, should the generated index.ssr.html be renamed to index.html as the primary html file. Thank you! – nova Aug 11 '20 at 01:17
  • Because in server side rendering you need node (yarn or npm) to run your project in server, so you can not copy the folder, you should run your project in server with nuxt command – soroush Aug 11 '20 at 06:30
0

There is the same question with my answer. There you will find necessary configs, so I do not want to copy the answer here, because it is better to keep everything in one place because of possible updates.

TitanFighter
  • 4,582
  • 3
  • 45
  • 73