Nuxt 3 Deployment Does Not Have Dist Directory

Hey folks,

I’m trying to deploy my toy app that uses Nuxt 3.

1:27:35 AM: build-image version: 73f16e520fdddf409be6f578c8c2c8941bdf32d3 (focal)
1:27:35 AM: buildbot version: aae36d37bb0728ee6dc52d97c5e1b5b83720773e
1:27:35 AM: Building without cache
1:27:35 AM: Starting to prepare the repo for build
1:27:35 AM: No cached dependencies found. Cloning fresh repo
1:27:35 AM: git clone --filter=blob:none https://github.com/do-kevin/nuxt-strapi
1:27:35 AM: Preparing Git Reference refs/heads/main
1:27:36 AM: Custom publish path detected. Proceeding with the specified path: 'frontend/dist'
1:27:37 AM: Starting to install dependencies
1:27:37 AM: Python version set to 3.8
1:27:37 AM: Attempting Ruby version 2.7.2, read from environment
1:27:38 AM: Using Ruby version 2.7.2
1:27:38 AM: Started restoring cached go cache
1:27:38 AM: Finished restoring cached go cache
1:27:39 AM: Installing Go version 1.19.13 (requested 1.19.x)
1:27:44 AM: go version go1.19.13 linux/amd64
1:27:44 AM: Using PHP version 8.0
1:27:46 AM: Downloading and installing node v18.18.0...
1:27:46 AM: Downloading https://nodejs.org/dist/v18.18.0/node-v18.18.0-linux-x64.tar.xz...
1:27:46 AM: Computing checksum with sha256sum
1:27:46 AM: Checksums matched!
1:27:48 AM: Now using node v18.18.0 (npm v9.8.1)
1:27:48 AM: Enabling Node.js Corepack
1:27:48 AM: Started restoring cached build plugins
1:27:48 AM: Finished restoring cached build plugins
1:27:48 AM: Started restoring cached corepack dependencies
1:27:48 AM: Finished restoring cached corepack dependencies
1:27:48 AM: Started restoring cached yarn cache
1:27:48 AM: Finished restoring cached yarn cache
1:27:49 AM: No yarn workspaces detected
1:27:49 AM: Started restoring cached node modules
1:27:49 AM: Finished restoring cached node modules
1:27:49 AM: Installing npm packages using Yarn version 1.22.19
1:27:49 AM: yarn install v1.22.19
1:27:49 AM: [1/4] Resolving packages...
1:27:49 AM: [2/4] Fetching packages...
1:27:49 AM: warning Pattern [wrap-ansi@^7.0.0] is trying to unpack in the same destination /opt/buildhome/.yarn_cache/v6/npm-wrap-ansi-cjs-7.0.0-67e145cff510a6a6984bdf1152911d69d2eb9e43-integrity/node_modules/wrap-ansi-cjs as pattern [wrap-ansi-cjs@npm:wrap-ansi@^7.0.0]. This could result in non-deterministic behavior, skipping.
1:27:58 AM: warning vscode-languageclient@7.0.0: The engine vscode appears to be invalid.
1:27:58 AM: [3/4] Linking dependencies...
1:27:58 AM: warning  > @nuxt/devtools@0.8.4 has unmet peer dependency vite@*.
1:27:58 AM: warning @nuxt/devtools > @nuxt/devtools-kit@0.8.4 has unmet peer dependency vite@*.
1:27:58 AM: warning @nuxt/devtools > vite-plugin-inspect@0.7.38 has unmet peer dependency vite@^3.1.0 || ^4.0.0.
1:27:58 AM: warning @nuxt/devtools > vite-plugin-vue-inspector@3.7.1 has unmet peer dependency vite@^3.0.0-0 || ^4.0.0-0.
1:27:58 AM: warning  > nuxt-vitest@0.10.3 has unmet peer dependency @vitejs/plugin-vue@*.
1:27:58 AM: warning  > nuxt-vitest@0.10.3 has unmet peer dependency @vitejs/plugin-vue-jsx@*.
1:27:58 AM: warning  > nuxt-vitest@0.10.3 has unmet peer dependency vite@*.
1:27:58 AM: warning nuxt-vitest > vitest-environment-nuxt@0.10.2 has unmet peer dependency vue@^3.2.45.
1:27:58 AM: warning nuxt-vitest > vitest-environment-nuxt@0.10.2 has unmet peer dependency vue-router@^4.0.0.
1:27:58 AM: warning nuxt-vitest > vitest-environment-nuxt > @vue/test-utils@2.4.1 has unmet peer dependency vue@^3.0.1.
1:28:01 AM: [4/4] Building fresh packages...
1:28:01 AM: $ nuxt prepare
1:28:03 AM: [success] Types generated in .nuxt
1:28:03 AM: Done in 13.63s.
1:28:03 AM: npm packages installed using Yarn
1:28:03 AM: Install dependencies script success
1:28:03 AM: Starting build script
1:28:04 AM: Detected 1 framework(s)
1:28:04 AM: nuxt at version 3.7.3
1:28:04 AM: Section completed: initializing
1:28:06 AM: ​
1:28:06 AM: Netlify Build                                                 
1:28:06 AM: ────────────────────────────────────────────────────────────────
1:28:06 AM: ​
1:28:06 AM: ❯ Version
1:28:06 AM:   @netlify/build 29.21.1
1:28:06 AM: ​
1:28:06 AM: ❯ Flags
1:28:06 AM:   baseRelDir: true
1:28:06 AM:   buildId: 650bfe75970324007256d7e1
1:28:06 AM:   deployId: 650bfe75970324007256d7e3
1:28:06 AM: ​
1:28:06 AM: ❯ Current directory
1:28:06 AM:   /opt/build/repo/frontend
1:28:06 AM: ​
1:28:06 AM: ❯ Config file
1:28:06 AM:   No config file was defined: using default values.
1:28:06 AM: ​
1:28:06 AM: ❯ Context
1:28:06 AM:   production
1:28:06 AM: ​
1:28:06 AM: Build command from Netlify app                                
1:28:06 AM: ────────────────────────────────────────────────────────────────
1:28:06 AM: ​
1:28:06 AM: $ NODE_ENV=production yarn build
1:28:06 AM: yarn run v1.22.19
1:28:06 AM: $ nuxt build
1:28:06 AM: [log] Nuxt 3.7.3 with Nitro 2.6.3
1:28:08 AM: [info] Building client...
1:28:08 AM: [info] vite v4.4.9 building for production...
1:28:08 AM: [info] transforming...
1:28:10 AM: [info] ✓ 358 modules transformed.
1:28:10 AM: [info] rendering chunks...
1:28:10 AM: [info] computing gzip size...
1:28:10 AM: [info] .nuxt/dist/client/manifest.json                     2.54 kB │ gzip:  0.45 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/error-500.c5df6088.css      1.95 kB │ gzip:  0.74 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/error-404.7fc72018.css      3.63 kB │ gzip:  1.12 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/default.511eeaa6.js         0.19 kB │ gzip:  0.17 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/index.353f92c9.js           0.36 kB │ gzip:  0.27 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/vue.f36acd1f.45e7ed9e.js    0.39 kB │ gzip:  0.26 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/error-500.a5ee59c1.js       1.92 kB │ gzip:  1.01 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/error-404.49ed13ee.js       2.29 kB │ gzip:  1.18 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/nuxt-link.cafa8b30.js       4.35 kB │ gzip:  1.87 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/entry.5be821b5.js         141.65 kB │ gzip: 53.69 kB
1:28:10 AM: [info] .nuxt/dist/client/_nuxt/restaurants.c5a54649.js   152.73 kB │ gzip: 47.92 kB
1:28:10 AM: [info] ✓ built in 2.36s
1:28:10 AM: [success] Client built in 2371ms
1:28:10 AM: [info] Building server...
1:28:10 AM: [info] vite v4.4.9 building SSR bundle for production...
1:28:10 AM: [info] transforming...
1:28:11 AM: [info] ✓ 82 modules transformed.
1:28:11 AM: [info] rendering chunks...
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-404-styles.1e0dde27.mjs        0.15 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-500-styles.cf4b3e80.mjs        0.15 kB
1:28:11 AM: [info] .nuxt/dist/server/styles.mjs                                 0.35 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/index-6a088328.js                    0.98 kB │ map:  4.83 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/default-e8bfe4a1.js                  1.04 kB │ map:  0.13 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/island-renderer-bdb201ea.js          1.09 kB │ map:  1.39 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/index-7045b1f7.js                    1.47 kB │ map:  0.45 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-500-styles-1.mjs-8fa81fcc.js   2.17 kB │ map:  0.12 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-500-cdb81d98.js                3.10 kB │ map:  3.78 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-404-styles-1.mjs-e0837f4f.js   3.86 kB │ map:  0.12 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/error-404-444d7c6a.js                4.00 kB │ map:  5.82 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/nuxt-link-3183829d.js                6.02 kB │ map: 13.29 kB
1:28:11 AM: [info] .nuxt/dist/server/_nuxt/restaurants-6622f3a2.js             11.79 kB │ map: 23.88 kB
1:28:11 AM: [info] .nuxt/dist/server/server.mjs                                37.53 kB │ map: 86.31 kB
1:28:11 AM: [info] ✓ built in 604ms
1:28:11 AM: [success] Server built in 612ms
1:28:11 AM: [error] ENOENT: no such file or directory, mkdir '/opt/build/repo/frontend/dist'
1:28:11 AM: [error] ENOENT: no such file or directory, mkdir '/opt/build/repo/frontend/dist'
1:28:11 AM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
1:28:11 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1:28:11 AM: ​
1:28:11 AM: build.command failed                                        
1:28:11 AM: ────────────────────────────────────────────────────────────────
1:28:11 AM: ​
1:28:11 AM:   Error message
1:28:11 AM:   Command failed with exit code 1: NODE_ENV=production yarn build (https://ntl.fyi/exit-code-1)
1:28:11 AM: ​
1:28:11 AM:   Error location
1:28:11 AM:   In Build command from Netlify app:
1:28:11 AM:   NODE_ENV=production yarn build
1:28:11 AM: ​
1:28:11 AM:   Resolved config
1:28:11 AM:   build:
1:28:11 AM:     base: /opt/build/repo/frontend
1:28:11 AM:     command: NODE_ENV=production yarn build
1:28:11 AM:     commandOrigin: ui
1:28:11 AM:     environment:
1:28:11 AM:       - APPLICATION_SERVER_URL
1:28:11 AM:     publish: /opt/build/repo/frontend/dist
1:28:11 AM:     publishOrigin: ui
1:28:12 AM: Caching artifacts
1:28:12 AM: Started saving node modules
1:28:12 AM: Finished saving node modules
1:28:12 AM: Started saving build plugins
1:28:12 AM: Finished saving build plugins
1:28:12 AM: Started saving corepack cache
1:28:12 AM: Finished saving corepack cache
1:28:12 AM: Started saving yarn cache
1:28:13 AM: Finished saving yarn cache
1:28:13 AM: Started saving pip cache
1:28:13 AM: Finished saving pip cache
1:28:13 AM: Started saving emacs cask dependencies
1:28:13 AM: Finished saving emacs cask dependencies
1:28:13 AM: Started saving maven dependencies
1:28:13 AM: Finished saving maven dependencies
1:28:13 AM: Started saving boot dependencies
1:28:13 AM: Finished saving boot dependencies
1:28:13 AM: Started saving rust rustup cache
1:28:13 AM: Finished saving rust rustup cache
1:28:13 AM: Started saving go dependencies
1:28:13 AM: Finished saving go dependencies
1:28:15 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:28:15 AM: Failing build: Failed to build site
1:28:15 AM: Finished processing build request in 40.093s
1:28:15 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
  • My build settings
Base directory
frontend

Package directory
Not set

Build command
yarn build

Publish directory
frontend/dist

Functions directory
frontend/netlify/functions
  • Package.json
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "test": "vitest"
  },

I don’t understand why my dist or .output folder are not detected? I’ve tried commenting those out on .gitignore.

Nevermind, I let gitgnore ignore dist and .output folders again. Removed those folders from the repo. I re-generated yarn.lock.

And I set my build settings as

Base directory
frontend

Package directory
Not set

Build command
yarn generate

Publish directory
frontend/dist

Hiya,

thanks for reaching back out and sharing your solution with the community this will help folks who come across this thread.