{"id":779,"hash":"fc14d24cc9f89119a5bafabb99ab994f2906686158e9b6358a2b4f8cd59d63a0","pattern":"ESBuild post-install failed when installing Vite","full_message":"I am using Vite as a bundler for a Nodejs project. When first installing Vite, everything is fine. But when I tried to install other packages again, I ran into the following error:\n\nnode_modules/esbuild postinstall$ node install.js\n│ node:internal/errors:867\n│   const err = new Error(message);\n│               ^\n│ Error: Command failed: /usr/local/bin/node /Volumes/Data/Develop/waterial-react/node_modules/esbuild/bin/esbuild --version\n│ /Volumes/Data/Develop/waterial-react/node_modules/esbuild/bin/esbuild:1\n│ ����\n│ SyntaxError: Invalid or unexpected token\n│     at internalCompileFunction (node:internal/vm:73:18)\n│     at wrapSafe (node:internal/modules/cjs/loader:1159:20)\n│     at Module._compile (node:internal/modules/cjs/loader:1203:27)\n│     at Module._extensions..js (node:internal/modules/cjs/loader:1293:10)\n│     at Module.load (node:internal/modules/cjs/loader:1096:32)\n│     at Module._load (node:internal/modules/cjs/loader:935:12)\n│     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12)\n│     at node:internal/main/run_main_module:23:47\n│ Node.js v19.4.0\n│     at checkExecSyncError (node:child_process:885:11)\n│     at Object.execFileSync (node:child_process:921:15)\n│     at validateBinaryVersion (/Volumes/Data/Develop/waterial-react/node_modules/esbuild/install.js:96:28)\n│     at /Volumes/Data/Develop/waterial-react/node_modules/esbuild/install.js:281:5 {\n│   status: 1,\n│   signal: null,\n│   output: [\n│     null,\n│     Buffer(0) [Uint8Array] [],\n│     Buffer(662) [Uint8Array] [\n│        47,  86, 111, 108, 117, 109, 101, 115,  47,  68,  97, 116,\n│        97,  47,  68, 101, 118, 101, 108, 111, 112,  47, 119,  97,\n│       116, 101, 114, 105,  97, 108,  45, 114, 101,  97,  99, 116,\n│        47, 110, 111, 100, 101,  95, 109, 111, 100, 117, 108, 101,\n│       115,  47, 101, 115,  98, 117, 105, 108, 100,  47,  98, 105,\n│       110,  47, 101, 115,  98, 117, 105, 108, 100,  58,  49,  10,\n│       239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189,\n│         7,  10,  10,  10,  83, 121, 110, 116,  97, 120,  69, 114,\n│       114, 111, 114,  58,\n│       ... 562 more items\n│     ]\n│   ],\n│   pid: 8362,\n│   stdout: Buffer(0) [Uint8Array] [],\n│   stderr: Buffer(662) [Uint8Array] [\n│      47,  86, 111, 108, 117, 109, 101, 115,  47,  68,  97, 116,\n│      97,  47,  68, 101, 118, 101, 108, 111, 112,  47, 119,  97,\n│     116, 101, 114, 105,  97, 108,  45, 114, 101,  97,  99, 116,\n│      47, 110, 111, 100, 101,  95, 109, 111, 100, 117, 108, 101,\n│     115,  47, 101, 115,  98, 117, 105, 108, 100,  47,  98, 105,\n│     110,  47, 101, 115,  98, 117, 105, 108, 100,  58,  49,  10,\n│     239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189,\n│       7,  10,  10,  10,  83, 121, 110, 116,  97, 120,  69, 114,\n│     114, 111, 114,  58,\n│     ... 562 more items\n│   ]\n│ }\n│ Node.js v19.4.0\n└─ Failed in 1.3s at /Volumes/Data/Develop/waterial-react/node_modules/esbuild\n ELIFECYCLE  Command failed with exit code 1.\n\nI am using pnpm as the package manager. I've found the issue esbuild #1703, #1953 and #1711 that might be related to this but didn't help much. I've tried to update Node.js to v19.4.0 but it didn't help.\n\nI am using Storybook with pnpm which requires the following .npmrc:\n\nauto-install-peers=true\nlegacy-peer-deps=true\nnode-linker=hoisted\nignore-workspace-root-check=true\n\nI don't know if this caused the issue. I tried to remove node_modules and do a clean install again and it worked. But I'm wondering if there's a solution to fix this entirely without removing node_modules every time I install something.\n\nI am using vite@^4.0.4 (latest) and pnpm@7.25.0 (also latest).\n\nThanks in advance!","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"I got the same error and fixed it by running:\n\nnpm install --save-dev --ignore-scripts esbuild@<vite-peerdependency-version>\n\nI don't think this is a permanent solution, but it fixed it for me.\n\nEDIT:\n\nI found a more permanent solution, I downgraded my Node version 16.11.1 and that fixed it. This solution worked on multiple computers.","confidence":0.7000000000000001,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/75115755/esbuild-post-install-failed-when-installing-vite","votes":6,"created_at":"2026-04-19T04:51:41.438307+00:00","updated_at":"2026-04-19T04:51:44.613157+00:00"}