Nuxt site failing to deploy with build command errors

I have a Nuxt site with target: static, and I have tried commands npm run build, npm generate, yarn generate and yarn build, all of them get an error and failed to deploy message. Please kindly advise. Thank you

Would it be possible for you to help us with the build log and possibly the repo?

Thank you for your reply. I’m unsure if you’ll have access to the repo, but this is the link:

Here is the log:

12:19:32 PM: build-image version: be42e453d6c8f171cc2f654acc29c0a8b60e6d93
12:19:32 PM: build-image tag: v3.7.1
12:19:32 PM: buildbot version: 6701b303fe187b6e99d4f597cb578b3348369cc2
12:19:32 PM: Building without cache
12:19:32 PM: Starting to prepare the repo for build
12:19:33 PM: No cached dependencies found. Cloning fresh repo
12:19:33 PM: git clone https://github.com/pcl-labs/playfi-repo
12:19:35 PM: Preparing Git Reference refs/heads/master
12:19:36 PM: Starting build script
12:19:36 PM: Installing dependencies
12:19:36 PM: Python version set to 2.7
12:19:38 PM: v12.18.0 is already installed.
12:19:38 PM: Now using node v12.18.0 (npm v6.14.4)
12:19:38 PM: Started restoring cached build plugins
12:19:38 PM: Finished restoring cached build plugins
12:19:39 PM: Attempting ruby version 2.7.1, read from environment
12:19:40 PM: Using ruby version 2.7.1
12:19:40 PM: Using PHP version 5.6
12:19:40 PM: Started restoring cached node modules
12:19:40 PM: Finished restoring cached node modules
12:19:40 PM: Installing NPM modules using NPM version 6.14.4
12:20:09 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/@nuxt/babel-preset-app/node_modules/core-js
12:20:09 PM: > node -e "try{require('./postinstall')}catch(e){}"
12:20:10 PM: > core-js@3.9.1 postinstall /opt/build/repo/node_modules/core-js
12:20:10 PM: > node -e "try{require('./postinstall')}catch(e){}"
12:20:10 PM: > nuxt@2.15.3 postinstall /opt/build/repo/node_modules/nuxt
12:20:10 PM: > opencollective || exit 0
12:20:12 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
12:20:12 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:20:12 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
12:20:12 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:20:12 PM: added 1635 packages from 592 contributors and audited 1638 packages in 30.362s
12:20:13 PM: 99 packages are looking for funding
12:20:13 PM:   run `npm fund` for details
12:20:13 PM: found 0 vulnerabilities
12:20:13 PM: NPM modules installed
12:20:13 PM: Started restoring cached go cache
12:20:13 PM: Finished restoring cached go cache
12:20:13 PM: go version go1.14.4 linux/amd64
12:20:13 PM: go version go1.14.4 linux/amd64
12:20:13 PM: Installing missing commands
12:20:13 PM: Verify run directory
12:20:15 PM: ​
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM:   Netlify Build                                                 
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM: ​
12:20:15 PM: ❯ Version
12:20:15 PM:   @netlify/build 10.2.5
12:20:15 PM: ​
12:20:15 PM: ❯ Flags
12:20:15 PM:   deployId: 606e9263ff61204dd93a2a06
12:20:15 PM: ​
12:20:15 PM: ❯ Current directory
12:20:15 PM:   /opt/build/repo
12:20:15 PM: ​
12:20:15 PM: ❯ Config file
12:20:15 PM:   No config file was defined: using default values.
12:20:15 PM: ​
12:20:15 PM: ❯ Context
12:20:15 PM:   production
12:20:15 PM: ​
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM:   1. Build command from Netlify app                             
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM: ​
12:20:15 PM: $ yarn build
12:20:15 PM: bash: yarn: command not found
12:20:15 PM: ​
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM:   "build.command" failed                                        
12:20:15 PM: ────────────────────────────────────────────────────────────────
12:20:15 PM: ​
12:20:15 PM:   Error message
12:20:15 PM:   Command failed with exit code 127: yarn build
12:20:15 PM: ​
12:20:15 PM:   Error location
12:20:15 PM:   In Build command from Netlify app:
12:20:15 PM:   yarn build
12:20:15 PM: ​
12:20:15 PM:   Resolved config
12:20:15 PM:   build:
12:20:15 PM:     command: yarn build
12:20:15 PM:     commandOrigin: ui
12:20:15 PM:     publish: /opt/build/repo/dist
12:20:16 PM: Caching artifacts
12:20:16 PM: Started saving node modules
12:20:16 PM: Finished saving node modules
12:20:16 PM: Started saving build plugins
12:20:16 PM: Finished saving build plugins
12:20:16 PM: Started saving pip cache
12:20:16 PM: Finished saving pip cache
12:20:16 PM: Started saving emacs cask dependencies
12:20:16 PM: Finished saving emacs cask dependencies
12:20:16 PM: Started saving maven dependencies
12:20:16 PM: Finished saving maven dependencies
12:20:16 PM: Started saving boot dependencies
12:20:16 PM: Finished saving boot dependencies
12:20:16 PM: Started saving rust rustup cache
12:20:16 PM: Finished saving rust rustup cache
12:20:16 PM: Started saving go dependencies
12:20:16 PM: Finished saving go dependencies
12:20:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:20:19 PM: Failing build: Failed to build site
12:20:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:20:19 PM: Finished processing build request in 46.443536433s```

Add a yarn.lock file to the root of your repo.

OR

Add an environment variable in Netlify UI with the name NETLIFY_USE_YARN and value as true. Refer: Manage build dependencies | Netlify Docs

For static you need to run:
npm run generate

You are missing the term ‘run’

I did a fresh install of yarn and the lock file was added. I ran build command yarn generate but I still get the error. The log is as followes:

3:53:05 PM: build-image version: be42e453d6c8f171cc2f654acc29c0a8b60e6d93
3:53:05 PM: build-image tag: v3.7.1
3:53:05 PM: buildbot version: 6701b303fe187b6e99d4f597cb578b3348369cc2
3:53:05 PM: Building without cache
3:53:05 PM: Starting to prepare the repo for build
3:53:06 PM: No cached dependencies found. Cloning fresh repo
3:53:06 PM: git clone https://github.com/pcl-labs/playfi-repo
3:53:07 PM: Preparing Git Reference refs/heads/master
3:53:08 PM: Starting build script
3:53:08 PM: Installing dependencies
3:53:08 PM: Python version set to 2.7
3:53:10 PM: v12.18.0 is already installed.
3:53:11 PM: Now using node v12.18.0 (npm v6.14.4)
3:53:11 PM: Started restoring cached build plugins
3:53:11 PM: Finished restoring cached build plugins
3:53:11 PM: Attempting ruby version 2.7.1, read from environment
3:53:13 PM: Using ruby version 2.7.1
3:53:13 PM: Using PHP version 5.6
3:53:13 PM: Started restoring cached yarn cache
3:53:13 PM: Finished restoring cached yarn cache
3:53:13 PM: Installing yarn at version 1.22.4
3:53:13 PM: Installing Yarn!
3:53:13 PM: > Downloading tarball...
3:53:13 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.5AiKOpGvaE
3:53:13 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
3:53:13 PM:                                  Dload  Upload   Total   Spent    Left  Speed
3:53:13 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
3:53:13 PM: 100    79  100    79    0     0    330      0 --:--:-- --:--:-- --:--:--   331
3:53:14 PM: 100    93  100    93    0     0    173      0 --:--:-- --:--:-- --:--:--   173
3:53:14 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
3:53:14 PM: 100   625  100   625    0     0    760      0 --:--:-- --:--:-- --:--:-- 11160
3:53:14 PM: 100 1215k  100 1215k    0     0  1001k      0  0:00:01  0:00:01 --:--:-- 1001k
3:53:14 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.5AiKOpGvaE.asc
3:53:14 PM: 100    84  100    84    0     0   1205      0 --:--:-- --:--:-- --:--:--  1205
3:53:14 PM: 100    97  100    97    0     0    989      0 --:--:-- --:--:-- --:--:--   989
3:53:14 PM: 100   629  100   629    0     0   5014      0 --:--:-- --:--:-- --:--:--  5014
3:53:14 PM: 100  1028  100  1028    0     0   7473      0 --:--:-- --:--:-- --:--:--  7473
3:53:14 PM: > Verifying integrity...
3:53:14 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
3:53:14 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
3:53:15 PM: gpg: WARNING: This key is not certified with a trusted signature!
3:53:15 PM: gpg:          There is no indication that the signature belongs to the owner.
3:53:15 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
3:53:15 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
3:53:15 PM: > GPG signature looks good
3:53:15 PM: > Extracting to ~/.yarn...
3:53:15 PM: > Adding to $PATH...
3:53:15 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
3:53:15 PM: Started restoring cached node modules
3:53:15 PM: Finished restoring cached node modules
3:53:15 PM: Installing NPM modules using Yarn version 1.22.4
3:53:16 PM: yarn install v1.22.4
3:53:16 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
3:53:16 PM: [1/4] Resolving packages...
3:53:17 PM: [2/4] Fetching packages...
3:53:37 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
3:53:37 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
3:53:37 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
3:53:37 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
3:53:37 PM: [3/4] Linking dependencies...
3:53:37 PM: warning "@nuxtjs/tailwindcss > @nuxt/postcss8 > css-loader@5.2.0" has unmet peer dependency "webpack@^4.27.0 || ^5.0.0".
3:53:37 PM: warning "@nuxtjs/tailwindcss > @nuxt/postcss8 > postcss-loader@4.2.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
3:53:47 PM: [4/4] Building fresh packages...
3:53:49 PM: Done in 32.88s.
3:53:49 PM: NPM modules installed using Yarn
3:53:49 PM: Started restoring cached go cache
3:53:49 PM: Finished restoring cached go cache
3:53:49 PM: go version go1.14.4 linux/amd64
3:53:49 PM: go version go1.14.4 linux/amd64
3:53:49 PM: Installing missing commands
3:53:49 PM: Verify run directory
3:53:51 PM: ​
3:53:51 PM: ────────────────────────────────────────────────────────────────
3:53:51 PM:   Netlify Build                                                 
3:53:51 PM: ────────────────────────────────────────────────────────────────
3:53:51 PM: ​
3:53:51 PM: ❯ Version
3:53:51 PM:   @netlify/build 10.2.5
3:53:51 PM: ​
3:53:51 PM: ❯ Flags
3:53:51 PM:   deployId: 606ec46f9933e99e7a5e6295
3:53:51 PM: ​
3:53:51 PM: ❯ Current directory
3:53:51 PM:   /opt/build/repo
3:53:51 PM: ​
3:53:51 PM: ❯ Config file
3:53:51 PM:   No config file was defined: using default values.
3:53:51 PM: ​
3:53:51 PM: ❯ Context
3:53:51 PM:   production
3:53:51 PM: ​
3:53:51 PM: ────────────────────────────────────────────────────────────────
3:53:51 PM:   1. Build command from Netlify app                             
3:53:51 PM: ────────────────────────────────────────────────────────────────
3:53:51 PM: ​
3:53:51 PM: $ yarn generate
3:53:52 PM: yarn run v1.22.4
3:53:52 PM: $ nuxt generate
3:54:23 PM: [fatal] Nuxt build error
3:54:23 PM:   ERROR in ./components/AppHero.vue?vue&type=template&id=81c47656& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppHero.vue?vue&type=template&id=81c47656&)
3:54:23 PM:   Module not found: Error: Can't resolve '../assets/images/frames/rectangle.png' in 'components'
  @ ./components/AppHero.vue?vue&type=template&id=81c47656& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppHero.vue?vue&type=template&id=81c47656&) 2:1881-1929
3:54:23 PM:   @ ./components/AppHero.vue?vue&type=template&id=81c47656&
3:54:23 PM:   @ ./components/AppHero.vue
3:54:23 PM:   @ ./pages/index.vue
3:54:23 PM:   @ ./node_modules/.cache/nuxt/router.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/index.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   ERROR in ./components/AppFooter.vue?vue&type=template&id=1a7badac& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppFooter.vue?vue&type=template&id=1a7badac&)
3:54:23 PM:   Module not found: Error: Can't resolve '../assets/logo/logo-nav.png' in 'components'
  @ ./components/AppFooter.vue?vue&type=template&id=1a7badac& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppFooter.vue?vue&type=template&id=1a7badac&) 2:288-326
3:54:23 PM:   @ ./components/AppFooter.vue?vue&type=template&id=1a7badac&
3:54:23 PM:   @ ./components/AppFooter.vue
3:54:23 PM:   @ ./layouts/default.vue
3:54:23 PM:   @ ./node_modules/.cache/nuxt/App.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/index.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   ERROR in ./components/Navbar.vue?vue&type=template&id=96e104f6& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/Navbar.vue?vue&type=template&id=96e104f6&)
3:54:23 PM:   Module not found: Error: Can't resolve '../assets/logo/logo-nav.png' in 'components'
  @ ./components/Navbar.vue?vue&type=template&id=96e104f6& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/Navbar.vue?vue&type=template&id=96e104f6&) 2:139-177
3:54:23 PM:   @ ./components/Navbar.vue?vue&type=template&id=96e104f6&
3:54:23 PM:   @ ./components/Navbar.vue
3:54:23 PM:   @ ./node_modules/.cache/nuxt/components/plugin.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/index.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   ERROR in ./components/AppFooter.vue?vue&type=template&id=1a7badac& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppFooter.vue?vue&type=template&id=1a7badac&)
3:54:23 PM:   Module not found: Error: Can't resolve '../assets/logo/powered-by.png' in 'components'
  @ ./components/AppFooter.vue?vue&type=template&id=1a7badac& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/AppFooter.vue?vue&type=template&id=1a7badac&) 2:1019-1059
3:54:23 PM:   @ ./components/AppFooter.vue?vue&type=template&id=1a7badac&
3:54:23 PM:   @ ./components/AppFooter.vue
3:54:23 PM:   @ ./layouts/default.vue
3:54:23 PM:   @ ./node_modules/.cache/nuxt/App.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/index.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   ERROR in ./components/Navbar.vue?vue&type=template&id=96e104f6& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/Navbar.vue?vue&type=template&id=96e104f6&)
3:54:23 PM:   Module not found: Error: Can't resolve '../assets/logo/powered-by.png' in 'components'
  @ ./components/Navbar.vue?vue&type=template&id=96e104f6& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/Navbar.vue?vue&type=template&id=96e104f6&) 2:972-1012
3:54:23 PM:   @ ./components/Navbar.vue?vue&type=template&id=96e104f6&
3:54:23 PM:   @ ./components/Navbar.vue
3:54:23 PM:   @ ./node_modules/.cache/nuxt/components/plugin.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/index.js
3:54:23 PM:   @ ./node_modules/.cache/nuxt/client.js
3:54:23 PM:   @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js
3:54:23 PM: 
3:54:23 PM:    ╭─────────────────────────────╮
3:54:23 PM:    │                             │
3:54:23 PM:    │   ✖ Nuxt Fatal Error        │
3:54:23 PM:    │                             │
3:54:23 PM:    │   Error: Nuxt build error   │
3:54:23 PM:    │                             │
3:54:23 PM:    ╰─────────────────────────────╯
3:54:23 PM: 
3:54:23 PM: error Command failed with exit code 1.
3:54:23 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
3:54:23 PM: ​
3:54:23 PM: ────────────────────────────────────────────────────────────────
3:54:23 PM:   "build.command" failed                                        
3:54:23 PM: ────────────────────────────────────────────────────────────────
3:54:23 PM: ​
3:54:23 PM:   Error message
3:54:23 PM:   Command failed with exit code 1: yarn generate
3:54:23 PM: ​
3:54:23 PM:   Error location
3:54:23 PM:   In Build command from Netlify app:
3:54:23 PM:   yarn generate
3:54:23 PM: ​
3:54:23 PM:   Resolved config
3:54:23 PM:   build:
3:54:23 PM:     command: yarn generate
3:54:23 PM:     commandOrigin: ui
3:54:23 PM:     publish: /opt/build/repo/dist
3:54:23 PM: Caching artifacts
3:54:23 PM: Started saving node modules
3:54:23 PM: Finished saving node modules
3:54:23 PM: Started saving build plugins
3:54:23 PM: Finished saving build plugins
3:54:23 PM: Started saving yarn cache
3:54:23 PM: Finished saving yarn cache
3:54:23 PM: Started saving pip cache
3:54:24 PM: Finished saving pip cache
3:54:24 PM: Started saving emacs cask dependencies
3:54:24 PM: Finished saving emacs cask dependencies
3:54:24 PM: Started saving maven dependencies
3:54:24 PM: Finished saving maven dependencies
3:54:24 PM: Started saving boot dependencies
3:54:24 PM: Finished saving boot dependencies
3:54:24 PM: Started saving rust rustup cache
3:54:24 PM: Finished saving rust rustup cache
3:54:24 PM: Started saving go dependencies
3:54:24 PM: Finished saving go dependencies
3:54:27 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:54:27 PM: Failing build: Failed to build site
3:54:27 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
3:54:27 PM: Finished processing build request in 1m21.490941199s```

So the yarn error got fixed, but this is a different error now.

As I can see, you’ve named the file: Rectangle.png in your repo:

image

But, you’re importing it as rectangle.png. The case needs to be same.

The same is probably true for other errors. The case of name is different.

It’s fixed. Thank you for your help. I actually had my images in an assets folder when I should have had them in the static one. After moving them and updating the URLs, it deployed. Thank you again for your help!