Deploy fails with: Failed to find package @netlify/esbuild-linux-64 on the file system

Sitename:
hejdoktor-next

Today I started to get the following error when deploying:

1:17:09 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
1:16:25 PM: build-image version: beb3f7b3d6069b85aae18cfa809c6c904c169629 (focal)
1:16:25 PM: buildbot version: 68b5b5b59af187aaf0b0e6ace7052ee0b5055e3d
1:16:25 PM: Building without cache
1:16:25 PM: Starting to prepare the repo for build
1:16:25 PM: No cached dependencies found. Cloning fresh repo
1:16:25 PM: git clone --filter=blob:none git@bitbucket.org:hejdoktor/hejdoktor-website.git
1:16:26 PM: Preparing Git Reference refs/heads/feature/codegen-graphql-WEB-262
1:16:27 PM: Custom build command detected. Proceeding with the specified command: 'npm run build'
1:16:27 PM: Starting to install dependencies
1:16:27 PM: Python version set to 3.8
1:16:27 PM: Attempting Ruby version 2.7.2, read from environment
1:16:28 PM: Using Ruby version 2.7.2
1:16:29 PM: Started restoring cached go cache
1:16:29 PM: Finished restoring cached go cache
1:16:29 PM: go version go1.19.11 linux/amd64
1:16:29 PM: Using PHP version 8.0
1:16:30 PM: Downloading and installing node v16.20.1...
1:16:30 PM: Downloading https://nodejs.org/dist/v16.20.1/node-v16.20.1-linux-x64.tar.xz...
1:16:30 PM: Computing checksum with sha256sum
1:16:31 PM: Checksums matched!
1:16:33 PM: Now using node v16.20.1 (npm v8.19.4)
1:16:33 PM: Enabling Node.js Corepack
1:16:33 PM: Started restoring cached build plugins
1:16:33 PM: Finished restoring cached build plugins
1:16:33 PM: Started restoring cached corepack dependencies
1:16:33 PM: Finished restoring cached corepack dependencies
1:16:33 PM: No npm workspaces detected
1:16:33 PM: Started restoring cached node modules
1:16:33 PM: Finished restoring cached node modules
1:16:33 PM: Installing npm packages using npm version 8.19.4
1:17:09 PM: npm ERR! code 1
1:17:09 PM: npm ERR! path /opt/build/repo/node_modules/@netlify/esbuild
1:17:09 PM: npm ERR! command failed
1:17:09 PM: npm ERR! command sh -c -- node install.js
1:17:09 PM: npm ERR! [esbuild] Failed to find package @netlify/esbuild-linux-64 on the file system
1:17:09 PM: npm ERR!
1:17:09 PM: npm ERR! This can happen if you use the --no-optional flag. The optionalDependencies
1:17:09 PM: npm ERR! package.json feature is used by esbuild to install the correct binary executable
1:17:09 PM: npm ERR! for your current platform. This install script will now attempt to work around
1:17:09 PM: npm ERR! this. If that fails, you need to remove the --no-optional flag to use esbuild.
1:17:09 PM: npm ERR!
1:17:09 PM: npm ERR! [esbuild] Trying to install package @netlify/esbuild-linux-64 using npm
1:17:09 PM: npm ERR! [esbuild] Failed to install package @netlify/esbuild-linux-64 using npm: ENOENT: no such file or directory, rename '/opt/build/repo/node_modules/esbuild/lib/npm-install/node_modules/@netlify/esbuild-linux-64/bin/esbuild' -> '/opt/build/repo/node_modules/esbuild/lib/downloaded-@netlify/esbuild-linux-64-esbuild'
1:17:09 PM: npm ERR! [esbuild] Trying to download https://registry.npmjs.org/@netlify/esbuild-linux-64/-/esbuild-linux-64-0.14.39.tgz
1:17:09 PM: npm ERR! [esbuild] Failed to download https://registry.npmjs.org/@netlify/esbuild-linux-64/-/esbuild-linux-64-0.14.39.tgz: ENOENT: no such file or directory, open '/opt/build/repo/node_modules/esbuild/lib/downloaded-@netlify/esbuild-linux-64-esbuild'
1:17:09 PM: npm ERR! /opt/build/repo/node_modules/@netlify/esbuild/install.js:241
1:17:09 PM: npm ERR!         throw new Error(`Failed to install package ${pkg}`);
1:17:09 PM: npm ERR!               ^
1:17:09 PM: npm ERR!
1:17:09 PM: npm ERR! Error: Failed to install package @netlify/esbuild-linux-64
1:17:09 PM: npm ERR!     at checkAndPreparePackage (/opt/build/repo/node_modules/@netlify/esbuild/install.js:241:15)
1:17:09 PM: npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
1:17:09 PM: npm ERR! A complete log of this run can be found in:
1:17:09 PM: npm ERR!     /opt/buildhome/.npm/_logs/2023-07-19T11_16_33_675Z-debug-0.log
1:17:09 PM: Error during npm install
1:17:09 PM: Build was terminated: dependency_installation script returned non-zero exit code: 1
1:17:09 PM: Failing build: Failed to install dependencies
1:17:09 PM: Finished processing build request in 44.949s

It worked the day before, and there haven’t been any changes to the package.json and netlify.toml since. Only an npm audit fix has made some changes to the package.lock. I’m on a Mac running node v16.20.1 and npm v8.19.4.

Dependencies from package.json:

"dependencies": {
    "@datocms/cli": "1.1.10",
    "@datocms/cma-client-node": "2.0.0",
    "@netlify/functions": "1.6.0",
    "@sentry/nextjs": "7.59.2",
    "@tailwindcss/container-queries": "0.1.1",
    "clsx": "1.2.1",
    "cookies-next": "2.1.2",
    "datocms-structured-text-to-html-string": "2.1.11",
    "datocms-structured-text-utils": "2.0.4",
    "dotenv": "16.3.1",
    "encoding": "0.1.13",
    "graphql": "16.7.1",
    "next": "13.3.4",
    "next-sitemap": "4.1.8",
    "react": "18.2.0",
    "react-datocms": "4.1.0",
    "react-dom": "18.2.0",
    "react-query": "3.39.3",
    "server-only": "0.0.1",
    "swiper": "8.4.7",
    "tinycolor2": "1.6.0"
  },
  "devDependencies": {
    "@graphql-codegen/cli": "4.0.1",
    "@graphql-codegen/client-preset": "4.0.1",
    "@netlify/plugin-nextjs": "4.39.1",
    "@storybook/addon-a11y": "7.1.0",
    "@storybook/addon-essentials": "7.1.0",
    "@storybook/addon-interactions": "7.1.0",
    "@storybook/addon-links": "7.1.0",
    "@storybook/blocks": "7.1.0",
    "@storybook/nextjs": "7.1.0",
    "@storybook/react": "7.1.0",
    "@storybook/testing-library": "0.2.0",
    "@svgr/webpack": "7.0.0",
    "@types/react": "18.2.15",
    "@types/tinycolor2": "1.4.3",
    "autoprefixer": "10.4.14",
    "change-case-all": "1.0.15",
    "concurrently": "8.2.0",
    "eslint": "8.45.0",
    "eslint-config-next": "13.4.10",
    "eslint-config-prettier": "8.8.0",
    "eslint-plugin-storybook": "0.6.12",
    "eslint-plugin-tailwindcss": "3.13.0",
    "husky": "8.0.3",
    "lint-staged": "13.2.3",
    "postcss": "8.4.26",
    "prettier": "3.0.0",
    "storybook": "7.1.0",
    "tailwindcss": "3.3.3",
    "typescript": "5.0.4"
  }

My netlify.toml file:

[build]
  publish = ".next"
  command = "npm run build"
  functions = "netlify/functions"

[functions]
  external_node_modules = ["keyv"]
  included_files = ["!node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node",
   "!node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node"]

[[plugins]]
  package = "@netlify/plugin-nextjs"
1 Like

It could deploy again after deleting node_modules and package-lock.json and running npm install on a Linux machine.

Not the greatest solution and only time will tell if it breaks the next time package-lock.json is updated from a Mac machine.