$ npm run start
> [email protected] start /home/app/ui/web
> nuxt start
FATAL No build files found in /home/app/ui/web/.nuxt/dist/server.
Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
Error happens when starting a Nuxt.js app in a Docker image that was built multi-stage:
npm ci && npm run build inside the build-stage image.nuxt, and also package.json and node_modules into the run-stage imageSome details regarding the environment.
Nuxt.js application mode is 'spa'. The missing files are really present inside the final image, no volumes/mounts have been used. OS user names are different between build-stage and run-stage images, however (hopefully) that should not be the case.
Nuxt.js 2.12.2, Node.js 14.16.0.
The nuxt.config.js was missing.
After I've copied it into the run-stage image, and switched from localhost to a 0.0.0.0 for server.host property inside the nuxt.config.js, container is running fine:
> [email protected] start /home/app/ui/web
> nuxt start
ℹ Listening on: http://172.17.0.2:3000/
Thus the required items for running a prod build in a server deployment mode are (seemingly) following:
/.nuxt
/node_modules
nuxt.config.js
package.json
The documentation is somehow vague regarding what should be included into the final artifact: https://nuxtjs.org/docs/2.x/get-started/commands/#server-deployment
A different SO question that inspired the troubleshooting: Nuxt deployment error: server resources are not available
Updated Nuxt to 2.15.3, switched from ad-hoc npm build to a reproducible build via yarn.
The build stage have become a yarn install --frozen-lockfile && yarn build. Also, copying node_modules from build stage into run stage brings development dependencies into prod, b/c prod build of Nuxt app requires development dependencies. Thus during a run stage, switched to a yarn install --frozen-lockfile --production=true instead of copying node_modules from a previous build stage.
The required items copied from a build stage for running a prod Nuxt app in a server deployment mode (https://nuxtjs.org/docs/2.x/features/deployment-targets/#server-hosting) are thus following:
/.nuxt
nuxt.config.js
package.json
yarn.lock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With