evanw/esbuild

Post install script fails with Expected "0.21.5" but got "0.21.4"

aminya opened this issue · 8 comments

When I run pnpm install, I get the following error.

     throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but…
           ^
 Error: Expected "0.21.5" but got "0.21.4"
     at validateBinaryVersion (./test
     at ./test/node_modules/esbuild/
 Node.js v20.14.0

Esbuild is my indirect dependency, and I don't have control over the version, and in the lock file, the versions are correct:


  '@esbuild/linux-x64@0.21.5':
    resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==}
    engines: {node: '>=12'}
    cpu: [x64]
    os: [linux]

  esbuild@0.21.5:
    resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
    engines: {node: '>=12'}
    hasBin: true

pnpm --version
9.3.0

Nothing has changed about esbuild’s installer recently. There was also another recent report of pnpm’s installer misbehaving. I’m guessing that pnpm has introduced a regression that is affecting esbuild. I suggest you file a bug with them and either use an older version of pnpm or use npm in the meantime. It would also be good to know which versions of pnpm have this bug and which do not.

I suspect it is related to using the hoisted node-linker and the fact that it is an indirect dependency. I've reported it in the pnpm repo

node-linker=hoisted
package-manager-strict=false

I'm closing this as this appears to be a problem with the package manager, not with the esbuild package.

Hitting this here as well

npm error path /blahblah/react-components/node_modules/esbuild
npm error command failed
npm error command sh -c node install.js
npm error /Users/blahblah/builds/PC/Portal/console/website/src/main/webapp/react-components/node_modules/esbuild/install.js:133
npm error     throw new Error(Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)});
npm error           ^
npm error
npm error Error: Expected "0.20.2" but got "0.21.5"

Also getting this issue in a CI Docker container.

npm 10.7.0
pnpm 8.15.8
Node v18.20.4

My only temporary workaround was to add esbuild as a peer dependency in my project (npm install esbuild) which will lock that version down on-install.

Another workaround. Remove node_modules and the pnpm-lock file and try again. Below the alias pnpm clean:node_modules deletes all node folders in a monorepo. Ymmv.

❯ pnpm add esbuild@latest -w -D
│     throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
│           ^
│ Error: Expected "0.23.1" but got "0.23.0"

❯ rm pnpm-lock.yaml
❯ pnpm clean:node_modules

❯ pnpm add esbuild@latest -w -D
node_modules/.pnpm/esbuild@0.23.1/node_modules/esbuild: Running postinstall script, done in 105ms

Currently stumbled on this issue, removing node_modules and pnpm-lock doesn't work for me.
esbuild is neither mentioned as dependencies nor devDependencies in my project.
adding/removing esbuild is also not a solution for me.

image

I setup an overrides in my package.json and set it to the newer version of the two... Dangerous, but does the trick.

{
  "pnpm": {
    "overrides": {
      "esbuild": "0.23.1"
    }
  }
}