今天使用pnpm下载依赖时出现esbuild报错
.../esbuild@0.14.54/node_modules/esbuild postinstall$ node install.js
│ node:internal/errors:857
│ const err = new Error(message);
│ ^
│ Error: Command failed: xxx/node_modules/.pnpm/esbuild@0.14.54/node_modules/esbuild/bin/esbuild --version
│ dyld: Symbol not found: _SecTrustEvaluateWithError
│ Referenced from: xxx/node_modules/.pnpm/esbuild@0.14.54/node_modules/esbuild/bin/esbuild
│ Expected in: flat namespace
│ at checkExecSyncError (node:child_process:861:11)
│ at Object.execFileSync (node:child_process:896:15)
│ at validateBinaryVersion (xxx/node_modules/.pnpm/esbuild@0.14.54/node_modules/esbuild/install.js:89:32)
│ at xxx/node_modules/.pnpm/esbuild@0.14.54/node_modules/esbuild/install.js:242:5 {
│ status: null,
│ signal: 'SIGABRT',
│ output: [
│ null,
│ Buffer(0) [Uint8Array] [],
│ Buffer(218) [Uint8Array] [
│ 100, 121, 108, 100, 58, 32, 83, 121, 109, 98, 111, 108,
│ 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 58, 32,
│ 95, 83, 101, 99, 84, 114, 117, 115, 116, 69, 118, 97,
│ 108, 117, 97, 116, 101, 87, 105, 116, 104, 69, 114, 114,
│ 111, 114, 10, 32, 32, 82, 101, 102, 101, 114, 101, 110,
│ 99, 101, 100, 32, 102, 114, 111, 109, 58, 32, 47, 85,
│ 115, 101, 114, 115, 47, 109, 105, 110, 103, 104, 117, 105,
│ 122, 104, 97, 110, 103, 47, 112, 114, 111, 106, 101, 99,
│ 116, 47, 108, 101,
│ ... 118 more items
│ ]
│ ],
│ pid: 6439,
│ stdout: Buffer(0) [Uint8Array] [],
│ stderr: Buffer(218) [Uint8Array] [
│ 100, 121, 108, 100, 58, 32, 83, 121, 109, 98, 111, 108,
│ 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 58, 32,
│ 95, 83, 101, 99, 84, 114, 117, 115, 116, 69, 118, 97,
│ 108, 117, 97, 116, 101, 87, 105, 116, 104, 69, 114, 114,
│ 111, 114, 10, 32, 32, 82, 101, 102, 101, 114, 101, 110,
│ 99, 101, 100, 32, 102, 114, 111, 109, 58, 32, 47, 85,
│ 115, 101, 114, 115, 47, 109, 105, 110, 103, 104, 117, 105,
│ 122, 104, 97, 110, 103, 47, 112, 114, 111, 106, 101, 99,
│ 116, 47, 108, 101,
│ ... 118 more items
│ ]
│ }
└─ Failed in 111ms
ELIFECYCLE Command failed with exit code 1.
报错信息提示:esbuild构建错误,原因是esbuild的版本有兼容问题,需要更换版本
解决方案: 在package.json中添加resolutions覆盖特定嵌套依赖的版本:
{
"resolutions": {
"esbuild": "npm:esbuild-wasm@latest"
//"esbuild": "<=0.14.27" //下载跨平台版本或者0.14.27以下
}
将node_modules删除,重新执行pnpm install即可解决