Npm run docs:build causing following errors

11:31:30 AM: Build ready to start

11:31:32 AM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)

11:31:32 AM: build-image tag: v4.8.0

11:31:32 AM: buildbot version: e552b142336b2b1222a93a4fd4cbed0019c77b46

11:31:33 AM: Fetching cached dependencies

11:31:33 AM: Failed to fetch cache, continuing with build

11:31:33 AM: Starting to prepare the repo for build

11:31:33 AM: No cached dependencies found. Cloning fresh repo

11:31:33 AM: git clone https://github.com/sachinbro/vue-project

11:31:34 AM: Preparing Git Reference refs/heads/main

11:31:34 AM: Parsing package.json dependencies

11:31:36 AM: Starting build script

11:31:36 AM: Installing dependencies

11:31:36 AM: Python version set to 2.7

11:31:37 AM: v16.14.2 is already installed.

11:31:38 AM: Now using node v16.14.2 (npm v8.5.0)

11:31:38 AM: Started restoring cached build plugins

11:31:38 AM: Finished restoring cached build plugins

11:31:38 AM: Attempting ruby version 2.7.2, read from environment

11:31:40 AM: Using ruby version 2.7.2

11:31:40 AM: Using PHP version 8.0

11:31:41 AM: No npm workspaces detected

11:31:41 AM: Started restoring cached node modules

11:31:41 AM: Finished restoring cached node modules

11:31:41 AM: Installing NPM modules using NPM version 8.5.0

11:32:01 AM: npm ERR! code EBADPLATFORM

11:32:01 AM: npm ERR! notsup Unsupported platform for esbuild-windows-64@0.14.36: wanted {“os”:“win32”,“arch”:“x64”} (current: {“os”:“linux”,“arch”:“x64”})

11:32:01 AM: npm ERR! notsup Valid OS: win32

11:32:01 AM: npm ERR! notsup Valid Arch: x64

11:32:01 AM: Creating deploy upload records

11:32:01 AM: npm ERR! notsup Actual OS: linux

11:32:01 AM: npm ERR! notsup Actual Arch: x64

11:32:01 AM: npm ERR! A complete log of this run can be found in:

11:32:01 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-04-16T05_46_42_589Z-debug-0.log

11:32:01 AM: Error during NPM install

11:32:01 AM: Build was terminated: Build script returned non-zero exit code: 1

11:32:01 AM: Failing build: Failed to build site

11:32:01 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1 (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)

11:32:01 AM: Finished processing build request in 28.663048611s

Hey @YeeP

It appears there is a dependency that is incompatible with Netlify Build because it is looking for Windows. If you have a package-lock.json or yarn.lock file, removing it may solve the issue.

thank you for the reply.
I did that already but it is still giving me same error.
By the way I am using vite as package manager.

Are you able to share the repository you are deploying from?

No I can’t sorry. I have made it private.

OK, we won’t be able to help unless you can share a copy of the repo that is failing. The advice that @coelmay is the same advice that I would have given you without access to your source code, so you can decide if you want to help us help you debug or not :slight_smile:

We we’re running into this same issue. We’re using vite to build and it apparently uses esbuild under the hood. When looking at esbuild in package-lock.json it has the following:

"node_modules/esbuild": {
      "version": "0.14.32",
      "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.32.tgz",
      "integrity": "sha512-RuzVUP/bkStmnVHK6Gh3gjaMjfXNLqBqvYVDiS9JKl5KdRdRLUeW5Wo8NrbL7cL6CW7Cyak7SvACqyPOBuA8vA==",
      "dev": true,
      "hasInstallScript": true,
      "bin": {
        "esbuild": "bin/esbuild"
      },
      "engines": {
        "node": ">=12"
      },
      "optionalDependencies": {
        "esbuild-android-64": "0.14.32",
        "esbuild-android-arm64": "0.14.32",
        "esbuild-darwin-64": "0.14.32",
        "esbuild-darwin-arm64": "0.14.32",
        "esbuild-freebsd-64": "0.14.32",
        "esbuild-freebsd-arm64": "0.14.32",
        "esbuild-linux-32": "0.14.32",
        "esbuild-linux-64": "0.14.32",
        "esbuild-linux-arm": "0.14.32",
        "esbuild-linux-arm64": "0.14.32",
        "esbuild-linux-mips64le": "0.14.32",
        "esbuild-linux-ppc64le": "0.14.32",
        "esbuild-linux-riscv64": "0.14.32",
        "esbuild-linux-s390x": "0.14.32",
        "esbuild-netbsd-64": "0.14.32",
        "esbuild-openbsd-64": "0.14.32",
        "esbuild-sunos-64": "0.14.32",
        "esbuild-windows-32": "0.14.32",
        "esbuild-windows-64": "0.14.32",
        "esbuild-windows-arm64": "0.14.32"
      }
    },

So I’m fairly certain this is where errors such as:
npm ERR! notsup Unsupported platform for esbuild-freebsd-arm64@0.14.32: wanted {"os":"freebsd","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
are coming from. We have also seen errors for other platforms such as Android failing.

I disagree that the solution should be to delete package-lock.json. This is an important file with a purpose and should be version controlled.

We have another repo that uses vite and has been building fine. We have warnings in the log but it doesn’t fail. I noticed that repo has a slightly newer version of esbuild. I updated our failing repo using npm update and it picked up a newer version of esbuild. Now we seem to be able to build the preview just fine. Again we have many warnings like:

2:59:00 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: esbuild-freebsd-arm64@0.14.49 (node_modules/esbuild-freebsd-arm64):
2:59:00 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-freebsd-arm64@0.14.49: wanted {"os":"freebsd","arch":"arm64"} (current: {"os":"linux","arch":"x64"})

but the build no longer fails.

1 Like

I am sorry, the problem was solved a long time ago. I forgot to update it here. And yes, your comment is the solution.
Thaank you

Thanks so much for coming back and letting us know, @edoyle :wave: I am glad everything is working for you now!