esbuild postinstall issue in npm install
Trying to run npm install and got this error. using react + vite node and npm latest version
npm error code 1
npm error path C:\Users\Asus\Desktop\CGN\cgn-frontend\node_modules\esbuild
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node install.js
npm error C:\Users\Asus\Desktop\CGN\cgn-frontend\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.21.5" but got ""
npm error at validateBinaryVersion (C:\Users\Asus\Desktop\CGN\cgn-frontend\node_modules\esbuild\install.js:133:11)
npm error at C:\Users\Asus\Desktop\CGN\cgn-frontend\node_modules\esbuild\install.js:281:5
npm error
npm error Node.js v22.6.0
I can't reproduce this issue using my Windows and your repo with vite. The error message seems to say the command esbuild --version returns an empty string. Can you test that in your node_modules manually?
> node node_modules\esbuild\bin\esbuild --version
0.21.5
:: if node_modules\esbuild\bin\esbuild is an exe, you can run it without node
> node_modules\esbuild\bin\esbuild --version
For your reference, here's what I did to migrate your project to vite in a second:
> npm pkg set type=module
> npm i -D vite @vitejs/plugin-react autoprefixer
Write a vite.config.js with contents below:
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()]
})
Start the server:
> npx vite
I'm closing this issue because it doesn't provide sufficient reproduction instructions.