We have an automated build that downloads npm, runs the build, and deploys to Azure blob storage. We're using the latest version (8.9.2). The angular project runs fine in development using npm start and builds without error using npm run publish
In development, we do get three warnings. The first two are at the beginning of the build:
Warning: Entry point 'abp-ng2-module' contains deep imports into 'C:/..../angular/node_modules/rxjs/internal/observable/throwError'. This is probably not a problem, but may cause the compilation of entry points to be out of order. Warning: Entry point 'angular2-text-mask' contains deep imports into 'C:/..../angular/node_modules/text-mask-core/dist/textMaskCore'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
The third is at the end of the build:
WARNING in Exceeded maximum budget for C:/..../angular/src/app/admin/subscription-management/invoice/invoice.component.less. Budget 6 kB was not met by 1.73 kB with a total of 7.73 kB.
During the automated build, we get the following error (sorry for how long this post is):
2020-06-11T17:14:43.0410088Z Compiling primeng : module as esm5 2020-06-11T17:14:43.0410500Z FATAL ERROR: NewArray Allocation failed - process out of memory 2020-06-11T17:14:43.0410726Z 1: 00007FF70011470F
followed by a long stack dump.
2020-06-11T17:14:43.0429465Z 80: 00007FFAD5F684D4 2020-06-11T17:14:43.0429620Z 81: 00007FFAD607E871 RtlUserThreadStart+33 2020-06-11T17:14:43.0429893Z FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory 2020-06-11T17:14:43.0430107Z 1: 00007FF70011470F
followed by more stack dump.
2020-06-11T17:14:43.0432221Z 16: 0000020F4108AC76 2020-06-11T17:14:43.0432406Z FATAL ERROR: NewArray Allocation failed - process out of memory 2020-06-11T17:14:43.0432775Z 1: 00007FF70011470F napi_wrap+113583 2020-06-11T17:14:43.0433006Z 2: 00007FF7000BF7D6 v8::base::CPU::has_sse+66646 2020-06-11T17:14:43.0433280Z 3: 00007FF7000C05D6 v8::base::CPU::has_sse+70230 2020-06-11T17:14:43.0433577Z 4: 00007FF7008D42EE v8::Isolate::ReportExternalAllocationLimitReached+94 2020-06-11T17:14:43.0434280Z 5: 00007FF7008BC3C1 v8::SharedArrayBuffer::Externalize+833 2020-06-11T17:14:43.0434574Z 6: 00007FF7008BC3EC v8::internal::FatalProcessOutOfMemory+12 2020-06-11T17:14:43.0434867Z 7: 00007FF7005BD728 v8::internal::ParseInfo::set_script+744 2020-06-11T17:14:43.0435213Z 8: 00007FF7005BD4FC v8::internal::ParseInfo::set_script+188 2020-06-11T17:14:43.0435505Z 9: 00007FF70057C62E v8::internal::Scanner::ScanString+238 2020-06-11T17:14:43.0435791Z 10: 00007FF700576808 v8::internal::Scanner::Next+2008 2020-06-11T17:14:43.0436148Z 11: 00007FF70059102C v8::internal::ParserBase<v8::internal::Parser>::ParseObjectPropertyDefinition+300
followed by further stack trace info
2020-06-11T17:14:43.0464829Z 76: 00007FF7000763A1 v8::internal::AsmJsScanner::GetIdentifierString+31777 2020-06-11T17:14:43.0465100Z 77: 00007FF7000E90E3 node::Start+275 2020-06-11T17:14:43.0465306Z 78: 00007FF6FFF56A9C RC4_options+340380 2020-06-11T17:14:43.0465618Z 79: 00007FF700DDF8C8 v8::internal::SetupIsolateDelegate::SetupHeap+1300536 2020-06-11T17:14:43.0465892Z 80: 00007FFAD5F684D4 BaseThreadInitThunk+20 2020-06-11T17:14:43.0466097Z 81: 00007FFAD607E871 RtlUserThreadStart+33 2020-06-11T17:14:43.0466308Z events.js:292 2020-06-11T17:14:43.0466478Z throw er; // Unhandled 'error' event 2020-06-11T17:14:43.0466705Z ^ 2020-06-11T17:14:43.0466794Z 2020-06-11T17:14:43.0466916Z Error: write UNKNOWN 2020-06-11T17:14:43.0467183Z at ChildProcess.target._send (internal/child_process.js:806:20) 2020-06-11T17:14:43.0467472Z at ChildProcess.target.send (internal/child_process.js:677:19) 2020-06-11T17:14:43.0467860Z at ChildProcessWorker._onExit (D:\a\9\s\node_modules\jest-worker\build\workers\ChildProcessWorker.js:310:21) 2020-06-11T17:14:43.0472281Z at ChildProcess.emit (events.js:315:20) 2020-06-11T17:14:43.0472623Z at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) 2020-06-11T17:14:43.0472914Z Emitted 'error' event on ChildProcess instance at: 2020-06-11T17:14:43.0473154Z at internal/child_process.js:810:39 2020-06-11T17:14:43.0473448Z at processTicksAndRejections (internal/process/task_queues.js:79:11) { 2020-06-11T17:14:43.0473672Z errno: 'UNKNOWN', 2020-06-11T17:14:43.0473824Z code: 'UNKNOWN', 2020-06-11T17:14:43.0473980Z syscall: 'write' 2020-06-11T17:14:43.0474144Z } 2020-06-11T17:14:43.0474270Z npm ERR! code ELIFECYCLE 2020-06-11T17:14:43.0474415Z npm ERR! errno 1 2020-06-11T17:14:43.0474645Z npm ERR! [email protected] publish:
gulp build && ng build --prod
2020-06-11T17:14:43.0474922Z npm ERR! Exit status 1 2020-06-11T17:14:43.0475054Z npm ERR! 2020-06-11T17:14:43.0475242Z npm ERR! Failed at the [email protected] publish script. 2020-06-11T17:14:43.0475555Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2020-06-11T17:14:43.0475800Z 2020-06-11T17:14:43.0475984Z npm ERR! A complete log of this run can be found in: 2020-06-11T17:14:43.0476264Z npm ERR! C:\npm\cache_logs\2020-06-11T17_14_42_548Z-debug.log
...
2020-06-11T17:14:44.2461677Z 13 verbose stack Error: [email protected] publish:
gulp build && ng build --prod
2020-06-11T17:14:44.2461971Z 13 verbose stack Exit status 1 2020-06-11T17:14:44.2462514Z 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 2020-06-11T17:14:44.2463023Z 13 verbose stack at EventEmitter.emit (events.js:315:20) 2020-06-11T17:14:44.2463537Z 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 2020-06-11T17:14:44.2463998Z 13 verbose stack at ChildProcess.emit (events.js:315:20) 2020-06-11T17:14:44.2464356Z 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 2020-06-11T17:14:44.2464709Z 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 2020-06-11T17:14:44.2465012Z 14 verbose pkgid [email protected] 2020-06-11T17:14:44.2465242Z 15 verbose cwd D:\a\9\s 2020-06-11T17:14:44.2465433Z 16 verbose Windows_NT 10.0.14393 2020-06-11T17:14:44.2465923Z 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run-script" "publish" 2020-06-11T17:14:44.2466268Z 18 verbose node v12.18.0 2020-06-11T17:14:44.2466453Z 19 verbose npm v6.14.4 2020-06-11T17:14:44.2466607Z 20 error code ELIFECYCLE 2020-06-11T17:14:44.2466924Z 21 error errno 1 2020-06-11T17:14:44.2467274Z 22 error [email protected] publish:gulp build && ng build --prod
2020-06-11T17:14:44.2467538Z 22 error Exit status 1 2020-06-11T17:14:44.2467740Z 23 error Failed at the [email protected] publish script. 2020-06-11T17:14:44.2468042Z 23 error This is probably not a problem with npm. There is likely additional logging output above. 2020-06-11T17:14:44.2468299Z 24 verbose exit [ 1, true ] 2020-06-11T17:14:44.2468441Z 2020-06-11T17:14:44.2765275Z ##[error]Error: Npm failed with return code: 1 2020-06-11T17:14:44.2876847Z ##[section]Finishing: npm run build
We're using Azure Piplines. Any help would be greatly appreciated.
9 Answer(s)
-
0
Hello devworkers,
what is happening here is that default memory defined in the configuration is insufficient for this node_modules By increasing the memory size , you should be able to build the angular project in production mode without issue.
Step 1 : First you should clear the build agents npm cache. Add a command line task before npm install or yarn task to the build pipeline and add following command into the command line task. npm cache clean --force Step 2: Then Update your Build Command in source code (in relevant file like package.json) gulp build && node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod
Refer too this also : https://stackoverflow.com/questions/46807355/heap-out-of-memory-in-angular4-while-ng-build-prod
-
0
While that seems to have improved the situation somewhat, I'm now getting this error:
2020-06-13T02:47:50.8303670Z Compiling ngx-spinner : module as esm5 2020-06-13T02:47:50.8303901Z Compiling primeng : module as esm5 2020-06-13T02:47:50.8304130Z events.js:292 2020-06-13T02:47:50.8304320Z throw er; // Unhandled 'error' event 2020-06-13T02:47:50.8304530Z ^ 2020-06-13T02:47:50.8304633Z 2020-06-13T02:47:50.8304805Z Error: write UNKNOWN 2020-06-13T02:47:50.8305050Z at ChildProcess.target._send (internal/child_process.js:806:20) 2020-06-13T02:47:50.8307458Z at ChildProcess.target.send (internal/child_process.js:677:19) 2020-06-13T02:47:50.8307870Z at ChildProcessWorker.send (D:\a\9\s\node_modules\jest-worker\build\workers\ChildProcessWorker.js:330:17) 2020-06-13T02:47:50.8308576Z at WorkerPool.send (D:\a\9\s\node_modules\jest-worker\build\WorkerPool.js:32:34) 2020-06-13T02:47:50.8309000Z at Farm._process (D:\a\9\s\node_modules\jest-worker\build\Farm.js:129:10) 2020-06-13T02:47:50.8309394Z at Farm._enqueue (D:\a\9\s\node_modules\jest-worker\build\Farm.js:152:10) 2020-06-13T02:47:50.8309831Z at Farm._push (D:\a\9\s\node_modules\jest-worker\build\Farm.js:159:12) 2020-06-13T02:47:50.8310189Z at D:\a\9\s\node_modules\jest-worker\build\Farm.js:90:14 2020-06-13T02:47:50.8310455Z at new Promise (<anonymous>) 2020-06-13T02:47:50.8310741Z at Farm.doWork (D:\a\9\s\node_modules\jest-worker\build\Farm.js:56:12) 2020-06-13T02:47:50.8311201Z at JestWorker._callFunctionWithArgs (D:\a\9\s\node_modules\jest-worker\build\index.js:178:23) 2020-06-13T02:47:50.8311671Z at TaskRunner.runTask (D:\a\9\s\node_modules\terser-webpack-plugin\dist\TaskRunner.js:41:26) 2020-06-13T02:47:50.8313054Z at enqueue (D:\a\9\s\node_modules\terser-webpack-plugin\dist\TaskRunner.js:89:35) 2020-06-13T02:47:50.8313497Z at D:\a\9\s\node_modules\terser-webpack-plugin\dist\TaskRunner.js:113:86 2020-06-13T02:47:50.8313923Z Emitted 'error' event on ChildProcess instance at: 2020-06-13T02:47:50.8314190Z at internal/child_process.js:810:39 2020-06-13T02:47:50.8314470Z at processTicksAndRejections (internal/process/task_queues.js:79:11) { 2020-06-13T02:47:50.8314760Z errno: 'UNKNOWN', 2020-06-13T02:47:50.8314920Z code: 'UNKNOWN', 2020-06-13T02:47:50.8316697Z syscall: 'write' 2020-06-13T02:47:50.8316885Z } 2020-06-13T02:47:50.8317084Z npm ERR! code ELIFECYCLE 2020-06-13T02:47:50.8317241Z npm ERR! errno 1 2020-06-13T02:47:50.8317994Z npm ERR! [email protected] publish:
gulp build && node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod
2020-06-13T02:47:50.8318344Z npm ERR! Exit status 1 2020-06-13T02:47:50.8318544Z npm ERR! 2020-06-13T02:47:50.8318747Z npm ERR! Failed at the [email protected] publish script. 2020-06-13T02:47:50.8319078Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2020-06-13T02:47:50.8319308Z 2020-06-13T02:47:50.8319556Z npm ERR! A complete log of this run can be found in: 2020-06-13T02:47:50.8319858Z npm ERR! C:\npm\cache_logs\2020-06-13T02_47_47_637Z-debug.log 2020-06-13T02:47:59.1535814Z Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache_logs\2020-06-13T02_47_47_637Z-debug.log 2020-06-13T02:47:59.1536265Z 0 info it worked if it ends with ok 2020-06-13T02:47:59.1621053Z 1 verbose cli [ 2020-06-13T02:47:59.1621291Z 1 verbose cli 'C:\Program Files\nodejs\node.exe', 2020-06-13T02:47:59.1621613Z 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 2020-06-13T02:47:59.1621938Z 1 verbose cli 'run-script', 2020-06-13T02:47:59.1622116Z 1 verbose cli 'publish' 2020-06-13T02:47:59.1622305Z 1 verbose cli ] 2020-06-13T02:47:59.1622462Z 2 info using [email protected] 2020-06-13T02:47:59.1622693Z 3 info using [email protected] 2020-06-13T02:47:59.1622924Z 4 verbose run-script [ 'prepublish', 'publish', 'postpublish' ] 2020-06-13T02:47:59.1623265Z 5 info lifecycle [email protected]~prepublish: [email protected] 2020-06-13T02:47:59.1623630Z 6 info lifecycle [email protected]~publish: [email protected] 2020-06-13T02:47:59.1624052Z 7 verbose lifecycle [email protected]~publish: unsafe-perm in lifecycle true -
0
Hi,
- Could you share content of C:\npm\cache_logs\2020-06-13T02_47_47_637Z-debug.log ?
- Could you increase
--max_old_space_size=8192
to a higher number and try again ?
Thanks,
-
0
It took me a little while to get the file you requested. I had to run a new build after increasing the --max_old_space_size to 10240. Here is the content of the log file:
0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run-script', 1 verbose cli 'publish' 1 verbose cli ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prepublish', 'publish', 'postpublish' ] 5 info lifecycle [email protected]~prepublish: [email protected] 6 info lifecycle [email protected]~publish: [email protected] 7 verbose lifecycle [email protected]~publish: unsafe-perm in lifecycle true 8 verbose lifecycle [email protected]~publish: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\a\9\s\node_modules.bin;C:\agents\2.170.1\externals\tf;C:\Program Files\Mercurial;C:\Program Files\MongoDB\Server\4.2\bin;C:\ProgramData\kind;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS;C:\Program Files\Mercurial;C:\hostedtoolcache\windows\stack\2.3.1\x64;C:\ProgramData\chocolatey\lib\ghc.8.10.1\tools\ghc-8.10.1\bin;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64\bin;C:\SeleniumWebDrivers\GeckoDriver;C:\Program Files (x86)\sbt\bin;C:\Rust.cargo\bin;C:\hostedtoolcache\windows\go\1.14.4\x64\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\hostedtoolcache\windows\Python\3.7.7\x64\Scripts;C:\hostedtoolcache\windows\Python\3.7.7\x64;C:\hostedtoolcache\windows\Ruby\2.5.8\x64\bin;C:\Program Files\PostgreSQL\12\bin;C:\npm\prefix;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;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\7;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\nodejs;C:\Program Files\PostgreSQL\12\bin;C:\Program Files\OpenSSL\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\Subversion\bin;C:\SeleniumWebDrivers\ChromeDriver;C:\SeleniumWebDrivers\EdgeDriver;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\CMake\bin;C:\Program Files\Amazon\AWSCLIV2;C:\Program Files\Amazon\AWSSAMCLI\bin;C:\Users\VssAdministrator.dotnet\tools;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps 9 verbose lifecycle [email protected]~publish: CWD: D:\a\9\s 10 silly lifecycle [email protected]~publish: Args: [ 10 silly lifecycle '/d /s /c', 10 silly lifecycle 'gulp build && node --max_old_space_size=10240 node_modules/@angular/cli/bin/ng build --prod' 10 silly lifecycle ] 11 silly lifecycle [email protected]~publish: Returned: code: 134 signal: null 12 info lifecycle [email protected]~publish: Failed to exec publish script 13 verbose stack Error: [email protected] publish:
gulp build && node --max_old_space_size=10240 node_modules/@angular/cli/bin/ng build --prod
13 verbose stack Exit status 134 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 14 verbose pkgid [email protected] 15 verbose cwd D:\a\9\s 16 verbose Windows_NT 10.0.14393 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run-script" "publish" 18 verbose node v12.18.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 134 22 error [email protected] publish:gulp build && node --max_old_space_size=10240 node_modules/@angular/cli/bin/ng build --prod
22 error Exit status 134 23 error Failed at the [email protected] publish script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 134, true ] -
0
Hi,
Do you use Azure pipeline to publish your app ? If so, Could you try this on your own PC to see if it fails or succeed ? This problem might be related to your Azure tier.
You can also try to add
--buildOptimizer=false
to your publish command. -
0
Yes, we use Azure pipelines. The build works on a local machine. What do you mean by the Azure tier? Are you suggesting we use a different build agent?
-
0
Perhaps you can try these steps :
Step 1:
$ npm cache clean --force
Step 2: Delete node_modules by$ rm -rf node_modules package-lock.json
folder Delete package-lock.json file too. Step 3:npm install
/ yarn To start again,$ npm run publish
https://stackoverflow.com/questions/42308879/npm-err-code-elifecycle
-
0
The --buildOptimizer=false argument seems to have fixed the build. I also went through and double checked the agents settings and switched to Ubuntu 20 -- not sure if that had anything to do with it. Anyway, thanks for your help.
-
0
Hello devworkers,
would you agree to share the yaml you are using to build and publish the angular part of your application ? I am currently working on it and find mysylf stuck on this matter.