Nuxt 3-rc3 failing to build during deployment

My url: https://starlit-croissant-bf711c.netlify.app/

I have a Nuxt 3 rc3 site that fetches content from Nitro. That content references a public Netlify Graph REST (not GraphQL) endpoint which belongs to an entirely different Netlify project.

Locally running npm run build builds successfully then running npm run preview runs the preview successfully. Not to mention, I tested this same project on Vercel and it ran without any issue.

I’m not using any environment variables. Locally, I tried trashing all my node dependencies, package-lock.json and disposable hidden directories, then reinstalled just to be sure. I specified an nvmrc version of 16.

On Netlify, I’m receiving a "build.command" failed error. I checked the support forums. There are plenty of issues regarding Search results for '"non-zero exit code: 1"' - Netlify Support Forums, but I haven’t found any relevant news regarding to my case.

Error message
3:48:15 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
3:48:15 PM: ​
3:48:15 PM:   Error location
3:48:15 PM:   In Build command from Netlify app:
3:48:15 PM:   npm run build
3:48:15 PM: ​
3:48:15 PM:   Resolved config
3:48:15 PM:   build:
3:48:15 PM:     command: npm run build
3:48:15 PM:     commandOrigin: ui
3:48:15 PM:     publish: /opt/build/repo/dist
3:48:15 PM:     publishOrigin: ui
3:48:16 PM: Caching artifacts
3:48:16 PM: Started saving node modules
3:48:16 PM: Finished saving node modules
3:48:16 PM: Started saving build plugins
3:48:16 PM: Finished saving build plugins
3:48:16 PM: Started saving pip cache
3:48:16 PM: Finished saving pip cache
3:48:16 PM: Started saving emacs cask dependencies
3:48:16 PM: Finished saving emacs cask dependencies
3:48:16 PM: Started saving maven dependencies
3:48:16 PM: Finished saving maven dependencies
3:48:16 PM: Started saving boot dependencies
3:48:16 PM: Finished saving boot dependencies
3:48:16 PM: Started saving rust rustup cache
3:48:16 PM: Finished saving rust rustup cache
3:48:16 PM: Started saving go dependencies
3:48:16 PM: Finished saving go dependencies
3:48:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:48:18 PM: Creating deploy upload records
3:48:18 PM: Failing build: Failed to build site
3:48:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:48:18 PM: Finished processing build request in 43.072083016s

Hey @djmtype

Can you share the full deploy log please as helpful information is appears missing from the snippet provided.

5:43:49 PM: Build ready to start
5:43:52 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
5:43:52 PM: build-image tag: v4.8.0
5:43:52 PM: buildbot version: a0072c9aa857edb8d0052da6c6482646b4348b94
5:43:52 PM: Fetching cached dependencies
5:43:52 PM: Failed to fetch cache, continuing with build
5:43:52 PM: Starting to prepare the repo for build
5:43:52 PM: No cached dependencies found. Cloning fresh repo
5:43:52 PM: git clone https://github.com/djmtype/nuxt3-netlify
5:43:53 PM: Preparing Git Reference refs/heads/main
5:43:53 PM: Parsing package.json dependencies
5:43:54 PM: Starting build script
5:43:54 PM: Installing dependencies
5:43:54 PM: Python version set to 2.7
5:43:55 PM: Attempting node version '16' from .nvmrc
5:43:56 PM: Downloading and installing node v16.15.0...
5:43:56 PM: Downloading https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz...
5:43:56 PM: Computing checksum with sha256sum
5:43:56 PM: Checksums matched!
5:44:00 PM: Now using node v16.15.0 (npm v8.5.5)
5:44:00 PM: Started restoring cached build plugins
5:44:00 PM: Finished restoring cached build plugins
5:44:00 PM: Attempting ruby version 2.7.2, read from environment
5:44:01 PM: Using ruby version 2.7.2
5:44:02 PM: Using PHP version 8.0
5:44:02 PM: No npm workspaces detected
5:44:02 PM: Started restoring cached node modules
5:44:02 PM: Finished restoring cached node modules
5:44:03 PM: Installing NPM modules using NPM version 8.5.5
5:44:11 PM: npm WARN deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
5:44:17 PM: added 649 packages, and audited 650 packages in 13s
5:44:17 PM: 79 packages are looking for funding
5:44:17 PM:   run `npm fund` for details
5:44:17 PM: found 0 vulnerabilities
5:44:17 PM: NPM modules installed
5:44:17 PM: Started restoring cached go cache
5:44:17 PM: Finished restoring cached go cache
5:44:17 PM: go version go1.16.5 linux/amd64
5:44:17 PM: go version go1.16.5 linux/amd64
5:44:17 PM: Installing missing commands
5:44:17 PM: Verify run directory
5:44:19 PM: ​
5:44:19 PM: ────────────────────────────────────────────────────────────────
5:44:19 PM:   Netlify Build                                                 
5:44:19 PM: ────────────────────────────────────────────────────────────────
5:44:19 PM: ​
5:44:19 PM: ❯ Version
5:44:19 PM:   @netlify/build 27.1.3
5:44:19 PM: ​
5:44:19 PM: ❯ Flags
5:44:19 PM:   baseRelDir: true
5:44:19 PM:   buildId: 6293e915302e981ab2b2657b
5:44:19 PM:   deployId: 6293e915302e981ab2b2657d
5:44:19 PM: ​
5:44:19 PM: ❯ Current directory
5:44:19 PM:   /opt/build/repo
5:44:19 PM: ​
5:44:19 PM: ❯ Config file
5:44:19 PM:   No config file was defined: using default values.
5:44:19 PM: ​
5:44:19 PM: ❯ Context
5:44:19 PM:   production
5:44:19 PM: ​
5:44:19 PM: ────────────────────────────────────────────────────────────────
5:44:19 PM:   1. Build command from Netlify app                             
5:44:19 PM: ────────────────────────────────────────────────────────────────
5:44:19 PM: ​
5:44:19 PM: $ npm run build
5:44:20 PM: > build
5:44:20 PM: > nuxt build
5:44:20 PM: [log] Nuxt CLI v3.0.0-rc.3
5:44:28 PM: [info] Vite client warmed up in 3211ms
5:44:28 PM: [info] Client built in 3334ms
5:44:28 PM: [info] Building server...
5:44:29 PM: [success] Server built in 1098ms
5:44:29 PM: [error] ENOENT: no such file or directory, mkdir '/opt/build/repo/dist'
5:44:29 PM: ​
5:44:29 PM: ────────────────────────────────────────────────────────────────
5:44:29 PM:   "build.command" failed                                        
5:44:29 PM: ────────────────────────────────────────────────────────────────
5:44:29 PM: ​
5:44:29 PM:   Error message
5:44:29 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
5:44:29 PM: ​
5:44:29 PM:   Error location
5:44:29 PM:   In Build command from Netlify app:
5:44:29 PM:   npm run build
5:44:29 PM: ​
5:44:29 PM:   Resolved config
5:44:29 PM:   build:
5:44:29 PM:     command: npm run build
5:44:29 PM:     commandOrigin: ui
5:44:29 PM:     publish: /opt/build/repo/dist
5:44:29 PM:     publishOrigin: ui
5:44:30 PM: Caching artifacts
5:44:30 PM: Started saving node modules
5:44:30 PM: Finished saving node modules
5:44:30 PM: Started saving build plugins
5:44:30 PM: Finished saving build plugins
5:44:30 PM: Started saving pip cache
5:44:30 PM: Finished saving pip cache
5:44:30 PM: Started saving emacs cask dependencies
5:44:30 PM: Finished saving emacs cask dependencies
5:44:30 PM: Started saving maven dependencies
5:44:30 PM: Finished saving maven dependencies
5:44:30 PM: Started saving boot dependencies
5:44:30 PM: Finished saving boot dependencies
5:44:30 PM: Started saving rust rustup cache
5:44:30 PM: Finished saving rust rustup cache
5:44:30 PM: Started saving go dependencies
5:44:30 PM: Finished saving go dependencies
5:44:32 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:44:32 PM: Creating deploy upload records
5:44:32 PM: Failing build: Failed to build site
5:44:32 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:44:33 PM: Finished processing build request in 40.639760619s

This is the relevant error (which was missing from your original post):

Likely because there is a dist that exists in the repository already which is not a directory, but a link to a local macOS directory.

Screen Shot 2022-05-30 at 8.05.39 am

As mentioned in the Nuxt Deployment Presents β†’ Netlify, Netlify automatically detects Nuxt, and writes to the appropriate directory(ies) such as dist. There is no need for the [build] section of the netlify.toml as you have.

I can now see a dist directory when I run npm run build locally. But, dist is purely a symlink to .output/public. Still, it’s unusual dist isn’t always shown in VS Code after running npm run build – even after refreshing the file structure. It just so happens it was there when I pushed my changes. I removed it and added ./dist to gitignore. It builds on Netlify now. Thanks for your help!

1 Like