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:
node_modules/esbuild postinstall$ node install.js
│ node:internal/errors:867
│ const err = new Error(message);
│ ^
│ Error: Command failed: /usr/local/bin/node /Volumes/Data/Develop/waterial-react/node_modules/esbuild/bin/esbuild --version
│ /Volumes/Data/Develop/waterial-react/node_modules/esbuild/bin/esbuild:1
│ ����
│ SyntaxError: Invalid or unexpected token
│ at internalCompileFunction (node:internal/vm:73:18)
│ at wrapSafe (node:internal/modules/cjs/loader:1159:20)
│ at Module._compile (node:internal/modules/cjs/loader:1203:27)
│ at Module._extensions..js (node:internal/modules/cjs/loader:1293:10)
│ at Module.load (node:internal/modules/cjs/loader:1096:32)
│ at Module._load (node:internal/modules/cjs/loader:935:12)
│ at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12)
│ at node:internal/main/run_main_module:23:47
│ Node.js v19.4.0
│ at checkExecSyncError (node:child_process:885:11)
│ at Object.execFileSync (node:child_process:921:15)
│ at validateBinaryVersion (/Volumes/Data/Develop/waterial-react/node_modules/esbuild/install.js:96:28)
│ at /Volumes/Data/Develop/waterial-react/node_modules/esbuild/install.js:281:5 {
│ status: 1,
│ signal: null,
│ output: [
│ null,
│ Buffer(0) [Uint8Array] [],
│ Buffer(662) [Uint8Array] [
│ 47, 86, 111, 108, 117, 109, 101, 115, 47, 68, 97, 116,
│ 97, 47, 68, 101, 118, 101, 108, 111, 112, 47, 119, 97,
│ 116, 101, 114, 105, 97, 108, 45, 114, 101, 97, 99, 116,
│ 47, 110, 111, 100, 101, 95, 109, 111, 100, 117, 108, 101,
│ 115, 47, 101, 115, 98, 117, 105, 108, 100, 47, 98, 105,
│ 110, 47, 101, 115, 98, 117, 105, 108, 100, 58, 49, 10,
│ 239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189,
│ 7, 10, 10, 10, 83, 121, 110, 116, 97, 120, 69, 114,
│ 114, 111, 114, 58,
│ ... 562 more items
│ ]
│ ],
│ pid: 8362,
│ stdout: Buffer(0) [Uint8Array] [],
│ stderr: Buffer(662) [Uint8Array] [
│ 47, 86, 111, 108, 117, 109, 101, 115, 47, 68, 97, 116,
│ 97, 47, 68, 101, 118, 101, 108, 111, 112, 47, 119, 97,
│ 116, 101, 114, 105, 97, 108, 45, 114, 101, 97, 99, 116,
│ 47, 110, 111, 100, 101, 95, 109, 111, 100, 117, 108, 101,
│ 115, 47, 101, 115, 98, 117, 105, 108, 100, 47, 98, 105,
│ 110, 47, 101, 115, 98, 117, 105, 108, 100, 58, 49, 10,
│ 239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189,
│ 7, 10, 10, 10, 83, 121, 110, 116, 97, 120, 69, 114,
│ 114, 111, 114, 58,
│ ... 562 more items
│ ]
│ }
│ Node.js v19.4.0
└─ Failed in 1.3s at /Volumes/Data/Develop/waterial-react/node_modules/esbuild
ELIFECYCLE Command failed with exit code 1.
I 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.
I am using Storybook with pnpm which requires the following .npmrc
:
auto-install-peers=true
legacy-peer-deps=true
node-linker=hoisted
ignore-workspace-root-check=true
I 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.
I am using vite@^4.0.4
(latest) and pnpm@7.25.0
(also latest).
Thanks in advance!