You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Node v20+Yarn v4(pnpm链接器)安装时esbuild构建失败求助

Yarn 4使用pnpm nodeLinker安装esbuild时出现EACCES权限错误

环境信息

  • Node v20.9.0
  • Yarn v4.0.2
  • yarnrc配置:nodeLinker: pnpm
  • 系统:Ubuntu 23.10
  • 多包workspaces项目

错误现象

执行yarn install时在Link阶段失败,报错信息:

➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failed
➤ YN0009: │ esbuild@npm:0.18.20 couldn't be built successfully (exit code 1, logs can be found here: /tmp/build.log)
➤ YN0000: └ Completed
➤ YN0000: · Failed with errors

build.log关键内容:

# Script name: postinstall

node:internal/errors:866
  const err = new Error(message);
              ^

Error: Command failed: /.local/share/nvm/v20.9.0/bin/node /node_modules/.store/esbuild-npm-0.18.20-004a76d281/package/bin/esbuild --version
node:child_process:929
    throw err;
    ^

<ref *1> Error: spawnSync /node_modules/.store/@esbuild-linux-x64-npm-0.18.20-de8e99b449/package/bin/esbuild EACCES

切换为nodeLinker: node-modules时,esbuild可正常安装。

问题原因

EACCES错误表明执行esbuild的二进制文件时缺少可执行权限。当Yarn使用pnpm nodeLinker时,包会被存储在.node_modules/.store目录下,该存储机制可能导致esbuild的二进制文件未被正确赋予可执行权限;此外,系统umask设置过严、nvm目录与Yarn存储目录的权限冲突也可能引发该问题。

解决方案

1. 直接修复esbuild二进制文件权限

找到对应版本的esbuild二进制文件,添加可执行权限:

chmod u+x .node_modules/.store/@esbuild-linux-x64-npm-0.18.20-de8e99b449/package/bin/esbuild

如果需要批量修复所有二进制文件:

find .node_modules/.store -path "*/bin/*" -type f -exec chmod u+x {} \;

2. 清理缓存后重新安装

清理Yarn缓存和现有依赖,重新执行安装:

yarn cache clean
rm -rf .node_modules yarn.lock
yarn install

3. 调整系统umask设置

如果系统umask设置过严(如0077),会导致下载的文件默认没有可执行权限。临时调整umask后再安装:

umask 0022
yarn install

4. 尝试直接使用pnpm CLI安装

既然采用pnpm的nodeLinker,直接使用pnpm CLI可能更兼容:

# 先全局安装pnpm
npm install -g pnpm
# 执行安装
pnpm install

内容的提问来源于stack exchange,提问作者Masoud Alipour

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 16:14:52