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

Angular 19.2.11+在Linux/Docker中启动构建失败(EsBuild权限错误)

Angular 19.2.11+ 在Oracle Linux/Docker环境中执行ng serve/ng build时的EsBuild权限错误

问题概述

从Angular 19.2.11版本开始,在Oracle Linux服务器或Docker构建环境中执行ng serve和ng build命令时,频繁遇到EsBuild相关异常。使用pnpm时会触发EACCES权限错误,切换至npm也无法解决,甚至npm安装依赖的过程都会失败。

pnpm执行时的报错信息

[root@SERVER test]# pnpm start

> test@0.0.0 start /home/pavan/test
> ng serve

An unhandled exception occurred: The service was stopped: spawn /home/pavan/test/node_modules/.pnpm/@esbuild+linux-x64@0.25.5/node_modules/@esbuild/linux-x64/bin/esbuild EACCES
See "/tmp/ng-Kg5jEg/angular-errors.log" for further details.
 ELIFECYCLE  Command failed.
[root@SERVER test]# cat /tmp/ng-Kg5jEg/angular-errors.log
[error] Error: The service was stopped: spawn /home/pavan/test/node_modules/.pnpm/@esbuild+linux-x64@0.25.5/node_modules/@esbuild/linux-x64/bin/esbuild EACCES
    at /home/pavan/test/node_modules/.pnpm/esbuild@0.25.5/node_modules/esbuild/lib/main.js:947:34
    at responseCallbacks.<computed> (/home/pavan/test/node_modules/.pnpm/esbuild@0.25.5/node_modules/esbuild/lib/main.js:601:9)
    at ChildProcess.afterClose (/home/pavan/test/node_modules/.pnpm/esbuild@0.25.5/node_modules/esbuild/lib/main.js:592:28)
    at ChildProcess.emit (node:events:524:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

npm安装依赖时的报错信息

[root@SERVER test]# npm i --legacy-peer-deps
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm error code 1
npm error path /home/pavan/test/node_modules/esbuild
npm error command failed
npm error command sh -c node install.js
npm error node:internal/errors:984
npm error   const err = new Error(message);
npm error               ^
npm error
npm error Error: Command failed: /home/pavan/test/node_modules/esbuild/bin/esbuild --version
npm error     at genericNodeError (node:internal/errors:984:15)
npm error     at wrappedFn (node:internal/errors:538:14)
npm error     at checkExecSyncError (node:child_process:891:11)
npm error     at Object.execFileSync (node:child_process:927:15)
npm error     at validateBinaryVersion (/home/pavan/test/node_modules/esbuild/install.js:101:28)
npm error     at /home/pavan/test/node_modules/esbuild/install.js:285:5 {
npm error   status: null,
npm error   signal: 'SIGSEGV',
npm error   output: [ null, Buffer(0) [Uint8Array] [], Buffer(0) [Uint8Array] [] ],
npm error   pid: 2777422,
npm error   stdout: Buffer(0) [Uint8Array] [],
npm error   stderr: Buffer(0) [Uint8Array] []
npm error }
npm error
npm error Node.js v20.19.2
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-05-30T02_54_12_695Z-debug-0.log

最小复现步骤

  • 将任意Angular代码仓库克隆到Oracle Linux或其他Linux系统中
  • 执行npm i 或 pnpm i && pnpm start

已尝试的无效方案

  • 切换pnpm、npm包管理工具
  • 更换Node.js 20、22、24版本

环境信息

Angular CLI: 20.0.0
Node: 20.19.2
Package Manager: pnpm 10.11.0
OS: linux x64

Angular: <error>
... build, common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.0 (cli-only)
@angular-devkit/core         20.0.0 (cli-only)
@angular-devkit/schematics   20.0.0 (cli-only)
@angular/cli                 20.0.0 (cli-only)
@schematics/angular          20.0.0 (cli-only)
rxjs                         7.8.2 (cli-only)
typescript                   <error>
zone.js                      <error>

解决建议

  1. 修复EsBuild二进制文件权限
    直接给EsBuild的可执行文件添加执行权限:

    # pnpm环境
    chmod +x /home/pavan/test/node_modules/.pnpm/@esbuild+linux-x64@0.25.5/node_modules/@esbuild/linux-x64/bin/esbuild
    
    # npm环境
    chmod +x /home/pavan/test/node_modules/esbuild/bin/esbuild
    
  2. 强制从源码编译EsBuild
    安装依赖前设置环境变量,跳过预编译二进制包下载,直接本地编译:

    # pnpm环境
    ESBUILD_FORCE_BUILD=true pnpm i
    
    # npm环境
    ESBUILD_FORCE_BUILD=true npm i --legacy-peer-deps
    
  3. 检查Oracle Linux的SELinux设置
    Oracle Linux默认启用SELinux,可能阻止EsBuild执行,临时关闭测试:

    setenforce 0
    

    若问题解决,可添加SELinux规则允许文件执行:

    chcon -t bin_t /home/pavan/test/node_modules/@esbuild/linux-x64/bin/esbuild
    
  4. Docker环境优化
    构建镜像时安装编译依赖,或强制源码编译:

    FROM node:20-alpine
    
    # 安装编译所需依赖
    RUN apk add --no-cache gcc g++ make python3
    
    WORKDIR /app
    COPY package*.json ./
    
    # 强制源码编译EsBuild
    ENV ESBUILD_FORCE_BUILD=true
    RUN npm install --legacy-peer-deps
    
    COPY . .
    CMD ["ng", "serve"]
    

内容的提问来源于stack exchange,提问作者Pavan Jadda

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 00:16:08