Search code examples
javascriptnode.jsnuxt.jsnuxt3.jsnitro

Nuxt 3 SSR with node-server as preset


I am building a nuxt 3 app with node-server as preset. This will be hosted on a server running node js. Npm run build produces .nuxt and .output correctly and I can see that .output has a node_modules in it.

The issue I have is that the .nuxt folder doesn't contain node_modules and to get it working I had to upload my local node_modules on the root folder of the server. Is there a way to get nuxt to build the output with node_modules for both .nuxt and .output?


Solution

  • For a production deployment with node-server preset you only need to copy the .output folder, as you have seen it already contains a copy of the node_modules folder (containing only the modules required at runtime). The .nuxt folder is only used during development and build process, but not required during runtime.

    Daniel Roe recently confirmed this on YouTube

    P.S.: If you have a Nuxt module that uses additional folders you should manually copy them (for example @nuxt/content uses the content folder in your project's root directory).