Azure Pipelines 中的 NG 构建失败,出现 NPM 错误 134 [英] NG Build fails in Azure Pipelines with NPM error 134

查看:29
本文介绍了Azure Pipelines 中的 NG 构建失败,出现 NPM 错误 134的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约 50% 的托管构建失败并显示 npm 错误 134.我正在使用托管 vs2017 构建具有相同构建定义的相同提交.我正在使用 Angular CLI 构建一个 Angular 应用程序.npm 任务调用run build",它在我的 package.json 中定义为ng build --prod".成功的构建和失败的构建都使用 npm 任务版本 1.1.49 和 npm 版本 6.8.这让我相信它与托管环境有关.托管的 vs2017 和 vs2019 代理几乎总是失败.而 Windows 容器代理大约有 50% 的时间会失败.

Approx 50% of my hosted builds are failing with npm error 134. I am building the same commit with the same build definition using hosted vs2017. I am building an Angular Application using the Angular CLI. The npm task calls 'run build' which is defined as "ng build --prod" in my package.json. Both a successful build and failed build are using npm task version 1.1.49 and npm verion 6.8. This leads me to believe it is something related to the hosted environment. The hosted vs2017 and vs2019 agents fail almost all of the time. While the windows container agent fails about 50% of the time.

npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! my-app@1.0.0 build: `ng build --prod`
npm ERR! Exit status 134
npm ERR! 
npm ERR! Failed at the my-app@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\TimeStampHere-debug.log
Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\TimeStampHere-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.8.0
3 info using node@v10.15.2
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle my-app@1.0.0~prebuild: my-app@1.0.0
6 info lifecycle my-app@1.0.0~build: my-app@1.0.0
7 verbose lifecycle my-app@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle my-app@1.0.0~build: PATH: C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;d:\a\1\s\ngmyapp\node_modules\.bin;C:\agents\2.149.2\externals\git\cmd;C:/hostedtoolcache/windows/Python/3.6.8/x64;C:/hostedtoolcache/windows/Python/3.6.8/x64/Scripts;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\Program Files\Boost\1.69.0;C:\Users\VssAdministrator\.dotnet\tools;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\zulu-8-azure-jdk_8.36.0.1-8.0.202-win_x64\bin;C:\npm\prefix;C:\hostedtoolcache\windows\Ruby\2.5.0\x64\bin;C:\Go1.11.5\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files\Microsoft MPI\Bin\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Docker;C:\Program Files\PowerShell\6\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\Subversion\bin;C:\Program Files\nodejs\;C:\Program Files\CMake\bin;C:\Program Files\Mercurial;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\OpenSSL\bin;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps;
9 verbose lifecycle my-app@1.0.0~build: CWD: d:\a\1\s\ngmyapp
10 silly lifecycle my-app@1.0.0~build: Args: [ '/d /s /c', 'ng build --prod' ]
11 silly lifecycle my-app@1.0.0~build: Returned: code: 134  signal: null
12 info lifecycle my-app@1.0.0~build: Failed to exec build script
13 verbose stack Error: my-app@1.0.0 build: `ng build --prod`
13 verbose stack Exit status 134
13 verbose stack     at EventEmitter.<anonymous> (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid my-app@1.0.0
15 verbose cwd d:\a\1\s\myapp
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v10.15.2
19 verbose npm  v6.8.0
20 error code ELIFECYCLE
21 error errno 134
22 error my-app@1.0.0 build: `ng build --prod`
22 error Exit status 134
23 error Failed at the my-app@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 134, true ]

##[error]Error: Npm failed with return code: 134
##[section]Finishing: npm build

我已经在内部配置了一个构建代理,我没有遇到这个问题.

I have configured a build agent on premise and I am not running into the issue.

推荐答案

问题的根源似乎是 node.js 内存不足.

It seems the root of issue is with node.js running out of memory.

https://github.com/angular/angular-cli/issues/13734

建议的解决方法是更改​​环境变量:

The suggested work around is to change a environment variable:

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod 

这篇关于Azure Pipelines 中的 NG 构建失败,出现 NPM 错误 134的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆