Netlify-cli/postinstall failing during build

Hi there! I can’t figure out why this build isn’t working. There seems to be some issue with the post install script for netlify-cli but i can’t understand why it’s throwing an error.

I’m working with this environment which has the netlify-toml file preconfigured. GitHub - lxy-yz/vitesse-lite-react: React fork of https://github.com/antfu/vitesse-lite

12:19:54 PM: Build ready to start
12:19:57 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
12:19:57 PM: build-image tag: v4.10.1
12:19:57 PM: buildbot version: aa4e1c51618610360476c8cb99b22ac3191f186e
12:19:57 PM: Fetching cached dependencies
12:19:57 PM: Starting to download cache of 159.0MB
12:19:59 PM: Finished downloading cache in 1.421303201s
12:19:59 PM: Starting to extract cache
12:20:02 PM: Finished extracting cache in 2.809630352s
12:20:02 PM: Finished fetching cache in 4.286633976s
12:20:02 PM: Starting to prepare the repo for build
12:20:02 PM: Preparing Git Reference refs/heads/master
12:20:03 PM: Parsing package.json dependencies
12:20:04 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'functions' versus '' in the Netlify UI
12:20:04 PM: Starting build script
12:20:04 PM: Installing dependencies
12:20:04 PM: Python version set to 2.7
12:20:04 PM: Started restoring cached node version
12:20:05 PM: Finished restoring cached node version
12:20:05 PM: v16.16.0 is already installed.
12:20:05 PM: Now using node v16.16.0 (npm v8.11.0)
12:20:05 PM: Started restoring cached build plugins
12:20:05 PM: Finished restoring cached build plugins
12:20:05 PM: Attempting ruby version 2.7.2, read from environment
12:20:06 PM: Using ruby version 2.7.2
12:20:06 PM: Using PHP version 8.0
12:20:06 PM: No npm workspaces detected
12:20:06 PM: Started restoring cached node modules
12:20:06 PM: Finished restoring cached node modules
12:20:07 PM: Installing NPM modules using NPM version 8.11.0
12:20:07 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:20:07 PM: npm WARN config location in the cache, and they are managed by
12:20:07 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:20:07 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:20:07 PM: npm WARN config location in the cache, and they are managed by
12:20:07 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:20:07 PM: 8.11.0
12:20:07 PM: NPM modules installed
12:20:07 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:20:07 PM: npm WARN config location in the cache, and they are managed by
12:20:07 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:20:07 PM: Started restoring cached go cache
12:20:07 PM: Finished restoring cached go cache
12:20:07 PM: Installing Go version 1.17 (requested 1.17)
12:20:12 PM: unset GOOS;
12:20:12 PM: unset GOARCH;
12:20:12 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
12:20:12 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
12:20:12 PM: go version >&2;
12:20:12 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
12:20:12 PM: go version go1.17 linux/amd64
12:20:12 PM: Installing missing commands
12:20:12 PM: Verify run directory
12:20:13 PM: ​
12:20:13 PM: ────────────────────────────────────────────────────────────────
12:20:13 PM:   Netlify Build                                                 
12:20:13 PM: ────────────────────────────────────────────────────────────────
12:20:13 PM: ​
12:20:13 PM: ❯ Version
12:20:13 PM:   @netlify/build 27.11.3
12:20:13 PM: ​
12:20:13 PM: ❯ Flags
12:20:13 PM:   baseRelDir: true
12:20:13 PM:   buildId: 62fa722afcb8b600090d9139
12:20:13 PM:   deployId: 62fa722afcb8b600090d913b
12:20:13 PM: ​
12:20:13 PM: ❯ Current directory
12:20:13 PM:   /opt/build/repo
12:20:13 PM: ​
12:20:13 PM: ❯ Config file
12:20:13 PM:   /opt/build/repo/netlify.toml
12:20:13 PM: ​
12:20:13 PM: ❯ Context
12:20:13 PM:   production
12:20:13 PM: ​
12:20:13 PM: ────────────────────────────────────────────────────────────────
12:20:13 PM:   1. build.command from netlify.toml                            
12:20:13 PM: ────────────────────────────────────────────────────────────────
12:20:13 PM: ​
12:20:13 PM: $ npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build
12:20:13 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
12:20:13 PM: npm WARN config location in the cache, and they are managed by
12:20:13 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
12:20:16 PM: npm WARN exec The following package was not found and will be installed: pnpm
12:20:17 PM: Lockfile is up to date, resolution step is skipped
12:20:17 PM: Progress: resolved 1, reused 0, downloaded 0, added 0
12:20:17 PM: Packages: +630
12:20:17 PM: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12:20:18 PM: Progress: resolved 630, reused 11, downloaded 87, added 95
12:20:19 PM: Progress: resolved 630, reused 11, downloaded 215, added 226
12:20:20 PM: Progress: resolved 630, reused 11, downloaded 414, added 430
12:20:21 PM: Progress: resolved 630, reused 11, downloaded 546, added 562
12:20:22 PM: Progress: resolved 630, reused 11, downloaded 613, added 630, done
12:20:22 PM: .../node_modules/@netlify/esbuild postinstall$ node install.js
12:20:22 PM: .../node_modules/@netlify/esbuild postinstall: Done
12:20:22 PM: .../node_modules/netlify-cli postinstall$ node ./scripts/postinstall.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: node:internal/modules/cjs/loader:936
12:20:23 PM: .../node_modules/netlify-cli postinstall:   throw err;
12:20:23 PM: .../node_modules/netlify-cli postinstall:   ^
12:20:23 PM: .../node_modules/netlify-cli postinstall: Error: Cannot find module 'bindings'
12:20:23 PM: .../node_modules/netlify-cli postinstall: Require stack:
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/analyze.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/node-file-trace.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/main.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/hash-fns.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/deploy-site.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/lib/http-agent.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/commands/base-command.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/commands/index.js
12:20:23 PM: .../node_modules/netlify-cli postinstall: - /opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/scripts/postinstall.js
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Module.require (node:internal/modules/cjs/loader:1005:19)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at require (node:internal/modules/cjs/helpers:102:18)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Object.<anonymous> (/opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/analyze.js:10:36)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Module._compile (node:internal/modules/cjs/loader:1105:14)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Module.load (node:internal/modules/cjs/loader:981:32)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
12:20:23 PM: .../node_modules/netlify-cli postinstall:     at Module.require (node:internal/modules/cjs/loader:1005:19) {
12:20:23 PM: .../node_modules/netlify-cli postinstall:   code: 'MODULE_NOT_FOUND',
12:20:23 PM: .../node_modules/netlify-cli postinstall:   requireStack: [
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/analyze.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/node-file-trace.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@vercel+nft@0.21.0/node_modules/@vercel/nft/out/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/@netlify+zip-it-and-ship-it@5.13.4/node_modules/@netlify/zip-it-and-ship-it/dist/main.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/hash-fns.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/deploy-site.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/deploy/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/utils/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/lib/http-agent.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/commands/base-command.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/src/commands/index.js',
12:20:23 PM: .../node_modules/netlify-cli postinstall:     '/opt/build/repo/node_modules/.pnpm/netlify-cli@10.17.4_@types+express@4.17.13/node_modules/netlify-cli/scripts/postinstall.js'
12:20:23 PM: .../node_modules/netlify-cli postinstall:   ]
12:20:23 PM: .../node_modules/netlify-cli postinstall: }
12:20:23 PM: .../node_modules/netlify-cli postinstall: Failed
12:20:23 PM:  ELIFECYCLE  Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
12:20:23 PM: ​
12:20:23 PM: ────────────────────────────────────────────────────────────────
12:20:23 PM:   "build.command" failed                                        
12:20:23 PM: ────────────────────────────────────────────────────────────────
12:20:23 PM: ​
12:20:23 PM:   Error message
12:20:23 PM:   Command failed with exit code 1: npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build (https://ntl.fyi/exit-code-1)
12:20:23 PM: ​
12:20:23 PM:   Error location
12:20:23 PM:   In build.command from netlify.toml:
12:20:23 PM:   npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build
12:20:23 PM: ​
12:20:23 PM:   Resolved config
12:20:23 PM:   build:
12:20:23 PM:     command: npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build
12:20:23 PM:     commandOrigin: config
12:20:23 PM:     environment:
12:20:23 PM:       - NPM_FLAGS
12:20:23 PM:       - NODE_VERSION
12:20:23 PM:     publish: /opt/build/repo/dist
12:20:23 PM:     publishOrigin: config
12:20:23 PM:   functionsDirectory: /opt/build/repo/functions
12:20:23 PM:   redirects:
12:20:23 PM:     - from: /*      status: 200      to: /index.html  redirectsOrigin: configCaching artifacts
12:20:23 PM: Started saving node modules
12:20:23 PM: Finished saving node modules
12:20:23 PM: Started saving build plugins
12:20:23 PM: Finished saving build plugins
12:20:23 PM: Started saving pip cache
12:20:23 PM: Finished saving pip cache
12:20:23 PM: Started saving emacs cask dependencies
12:20:23 PM: Finished saving emacs cask dependencies
12:20:23 PM: Started saving maven dependencies
12:20:23 PM: Finished saving maven dependencies
12:20:23 PM: Started saving boot dependencies
12:20:23 PM: Finished saving boot dependencies
12:20:23 PM: Started saving rust rustup cache
12:20:23 PM: Finished saving rust rustup cache
12:20:23 PM: Started saving go dependencies
12:20:23 PM: Finished saving go dependencies
12:20:23 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:20:23 PM: Creating deploy upload records
12:20:24 PM: Failing build: Failed to build site
12:20:24 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
12:20:24 PM: Finished processing build request in 26.78126576s

My netlify.toml is

[build.environment]
  NPM_FLAGS = "--version"
  NODE_VERSION = "16"

[build]
  functions = "functions"
  publish = "dist"
  command = "CI= npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

The website domain is ‘ntnle.me

I’d appreciate any guidance or direction. Thanks!

I wonder why you’re installing Node Modules twice though? Once Netlify does it for your automatically, and then you’re manually installing it again for some reason.

Additionally, is there a specific reason for having Netlify CLI in your package.json?