Base solution for your next web application
Open Closed

npm run publish VERY SLOW #5554


User avatar
0
blueoceandev created

We are noticed in our automated builds that the "npm run publish" step to build the angular front end is very slow.. Its taking upwards of 15 minutes (usually around 5 minutes). When building locally it looks like maybe the source map generation is the issue... But when I try to avoid source map generation (--no-sourcemap) then the build fails with the following.

Are there any known ways to get that build step sped up?


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @catapult you can check angular-cli's github repo for performance suggestions. I also couldn't see the error you are getting when using --no-sourcemap.

  • User Avatar
    0
    blueoceandev created

    Sorry I forgot to include the build output..

    So background I have tweaked the package.json publish command so that I can get around some of the build performance issues (per some angular threads I looked at before posting here).. The last optimization I was trying was to add --no-sourcemap to the ng build command.. Below is the output from the build agent.

    The specific error is "Unknown option: '--sourcemap'"

    2018-08-27T17:49:09.8509243Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version" 2018-08-27T17:49:09.8509243Z 5.6.0 2018-08-27T17:49:15.4710273Z Unknown option: '--sourcemap' 2018-08-27T17:49:15.4710273Z npm ERR! code ELIFECYCLE 2018-08-27T17:49:15.4710273Z npm ERR! errno 1 2018-08-27T17:49:15.4710273Z npm ERR! [email protected] publish: node --max-old-space-size=3072 node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap 2018-08-27T17:49:15.4710273Z npm ERR! Exit status 1 2018-08-27T17:49:15.4710273Z npm ERR! 2018-08-27T17:49:15.4710273Z npm ERR! Failed at the [email protected] publish script. 2018-08-27T17:49:15.4710273Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z npm ERR! A complete log of this run can be found in: 2018-08-27T17:49:15.4710273Z npm ERR! C:\Users\vstsAdmin\AppData\Roaming\npm-cache_logs\2018-08-27T17_49_15_115Z-debug.log 2018-08-27T17:49:15.4710273Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list" 2018-08-27T17:49:15.4710273Z ; cli configs 2018-08-27T17:49:15.4710273Z metrics-registry = "https://registry.npmjs.org/" 2018-08-27T17:49:15.4710273Z scope = "" 2018-08-27T17:49:15.4710273Z user-agent = "npm/5.6.0 node/v8.11.4 win32 x64" 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z ; environment configs 2018-08-27T17:49:15.4710273Z userconfig = "d:\work\1\2\npm\551.npmrc" 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z ; builtin config undefined 2018-08-27T17:49:15.4710273Z prefix = "C:\Users\vstsAdmin\AppData\Roaming\npm" 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z ; node bin location = C:\Program Files\nodejs\node.exe 2018-08-27T17:49:15.4710273Z ; cwd = d:\work\1\2\s\RTS\angular 2018-08-27T17:49:15.4710273Z ; HOME = C:\Users\vstsAdmin 2018-08-27T17:49:15.4710273Z ; "npm config ls -l" to show all defaults. 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run publish" 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.4710273Z > [email protected] publish d:\work\1\2\s\RTS\angular 2018-08-27T17:49:15.4710273Z > node --max-old-space-size=3072 node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap 2018-08-27T17:49:15.4710273Z 2018-08-27T17:49:15.5491544Z Found npm debug log, make sure the path matches with the one in npm's output: C:\Users\vstsAdmin\AppData\Roaming\npm-cache_logs\2018-08-27T17_49_15_115Z-debug.log 2018-08-27T17:49:15.5491544Z 0 info it worked if it ends with ok 2018-08-27T17:49:15.5491544Z 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 2018-08-27T17:49:15.5491544Z 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 2018-08-27T17:49:15.5491544Z 1 verbose cli 'run', 2018-08-27T17:49:15.5491544Z 1 verbose cli 'publish' ] 2018-08-27T17:49:15.5491544Z 2 info using [email protected] 2018-08-27T17:49:15.5491544Z 3 info using [email protected] 2018-08-27T17:49:15.5491544Z 4 verbose run-script [ 'prepublish', 'publish', 'postpublish' ] 2018-08-27T17:49:15.5491544Z 5 info lifecycle [email protected]~prepublish: [email protected] 2018-08-27T17:49:15.5491544Z 6 info lifecycle [email protected]~publish: [email protected] 2018-08-27T17:49:15.5491544Z 7 verbose lifecycle [email protected]~publish: unsafe-perm in lifecycle true 2018-08-27T17:49:15.5491544Z 8 verbose lifecycle [email protected]~publish: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;d:\work\1\2\s\RTS\angular\node_modules.bin;C:\agent\externals\git\cmd;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin;C:\Users\vstsAdmin\AppData\Local\Microsoft\WindowsApps;C:\Users\vstsAdmin.dotnet\tools;C:\Users\vstsAdmin\AppData\Roaming\npm;C:\Users\vstsAdmin\AppData\Local\Yarn\bin;C:\agent\bin;C:\agent\bin 2018-08-27T17:49:15.5491544Z 9 verbose lifecycle [email protected]~publish: CWD: d:\work\1\2\s\RTS\angular 2018-08-27T17:49:15.5491544Z 10 silly lifecycle [email protected]~publish: Args: [ '/d /s /c', 2018-08-27T17:49:15.5491544Z 10 silly lifecycle 'node --max-old-space-size=3072 node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap' ] 2018-08-27T17:49:15.5491544Z 11 silly lifecycle [email protected]~publish: Returned: code: 1 signal: null 2018-08-27T17:49:15.5491544Z 12 info lifecycle [email protected]~publish: Failed to exec publish script 2018-08-27T17:49:15.5491544Z 13 verbose stack Error: [email protected] publish: node --max-old-space-size=3072 node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap 2018-08-27T17:49:15.5491544Z 13 verbose stack Exit status 1 2018-08-27T17:49:15.5491544Z 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16) 2018-08-27T17:49:15.5491544Z 13 verbose stack at emitTwo (events.js:126:13) 2018-08-27T17:49:15.5491544Z 13 verbose stack at EventEmitter.emit (events.js:214:7) 2018-08-27T17:49:15.5491544Z 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 2018-08-27T17:49:15.5491544Z 13 verbose stack at emitTwo (events.js:126:13) 2018-08-27T17:49:15.5491544Z 13 verbose stack at ChildProcess.emit (events.js:214:7) 2018-08-27T17:49:15.5491544Z 13 verbose stack at maybeClose (internal/child_process.js:925:16) 2018-08-27T17:49:15.5491544Z 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 2018-08-27T17:49:15.5491544Z 14 verbose pkgid [email protected] 2018-08-27T17:49:15.5491544Z 15 verbose cwd d:\work\1\2\s\RTS\angular 2018-08-27T17:49:15.5491544Z 16 verbose Windows_NT 10.0.14393 2018-08-27T17:49:15.5491544Z 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "publish" 2018-08-27T17:49:15.5491544Z 18 verbose node v8.11.4 2018-08-27T17:49:15.5491544Z 19 verbose npm v5.6.0 2018-08-27T17:49:15.5491544Z 20 error code ELIFECYCLE 2018-08-27T17:49:15.5491544Z 21 error errno 1 2018-08-27T17:49:15.5491544Z 22 error [email protected] publish: node --max-old-space-size=3072 node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap 2018-08-27T17:49:15.5491544Z 22 error Exit status 1 2018-08-27T17:49:15.5491544Z 23 error Failed at the [email protected] publish script. 2018-08-27T17:49:15.5491544Z 23 error This is probably not a problem with npm. There is likely additional logging output above. 2018-08-27T17:49:15.5491544Z 24 verbose exit [ 1, true ] 2018-08-27T17:49:15.5491544Z 2018-08-27T17:49:15.5679041Z ##[error]Error: Npm failed with return code: 1 2018-08-27T17:49:15.5805639Z ##[section]Async Command Start: Telemetry 2018-08-27T17:49:15.5805639Z ##[section]Async Command End: Telemetry 2018-08-27T17:49:15.5805639Z ##[section]Async Command Start: Telemetry 2018-08-27T17:49:15.5960432Z ##[section]Async Command End: Telemetry 2018-08-27T17:49:15.5960432Z ##[section]Finishing: Ng Build

  • User Avatar
    0
    alper created
    Support Team

    Hi,

    The default value of --source-map is true. So to disable sourcemaps use the below command

    ng build --source-map=false
    

    Similarly --prod avoids creating sourcemaps by default but if you want to create then just use --source-map in the end to create sourcemaps.

    --sourceMap=false
    

    <a class="postlink" href="https://github.com/angular/angular-cli/issues/10676">https://github.com/angular/angular-cli/issues/10676</a>