Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error starting Nuxt.js app: No build files found

Tags:

docker

nuxt.js

$ 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:

  1. npm ci && npm run build inside the build-stage image
  2. copy the built app .nuxt, and also package.json and node_modules into the run-stage image

Some 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.

like image 615
Sand Pipersburg Avatar asked Jan 30 '26 20:01

Sand Pipersburg


1 Answers

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

Update

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
like image 151
Sand Pipersburg Avatar answered Feb 02 '26 12:02

Sand Pipersburg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!