2

I am working with Azure DevOps CI/CD for Angular 7 project but it is failing with following at the time of building angular code:

Error: Npm failed with return code: 1

Going through the pipeline task log I found that Node is exiting with following error:

2019-05-27T06:57:25.6984762Z npm verb lifecycle [email protected]~build: CWD: D:\a\1\s\Client 2019-05-27T06:57:25.6984945Z npm info lifecycle [email protected]~build: Failed to exec build script 2019-05-27T06:57:25.6985117Z npm verb stack Error: [email protected] build: node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev "--prod" 2019-05-27T06:57:25.6985258Z npm verb stack Exit status 1 2019-05-27T06:57:25.6985401Z npm verb stack at EventEmitter. (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16) 2019-05-27T06:57:25.6985577Z npm verb stack at EventEmitter.emit (events.js:189:13) 2019-05-27T06:57:25.6985721Z npm verb stack at ChildProcess. (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 2019-05-27T06:57:25.6986143Z npm verb stack at ChildProcess.emit (events.js:189:13) 2019-05-27T06:57:25.6986311Z npm verb stack at maybeClose (internal/child_process.js:970:16) 2019-05-27T06:57:25.6986453Z npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 2019-05-27T06:57:25.6986609Z npm verb pkgid [email protected] 2019-05-27T06:57:25.6986743Z npm verb cwd D:\a\1\s\Client 2019-05-27T06:57:25.6986877Z npm verb Windows_NT 10.0.14393 2019-05-27T06:57:25.6987017Z npm verb argv "C:\Program Files\nodejs\node.exe" "C:\npm\prefix\node_modules\npm\bin\npm-cli.js" "run" "build" "--" "--prod" 2019-05-27T06:57:25.6987169Z npm verb node v10.15.3 2019-05-27T06:57:25.6987304Z npm verb npm v6.9.0 2019-05-27T06:57:25.6987435Z npm ERR! code ELIFECYCLE 2019-05-27T06:57:25.6987584Z npm ERR! errno 1 2019-05-27T06:57:25.6987890Z npm ERR! [email protected] build: node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev "--prod" 2019-05-27T06:57:25.6988173Z npm ERR! Exit status 1

I tried looking through different threads based upon error keywords but have not found a fix yet. Please note that everything works fine in the development environment.

I am not allowed to attach file or image so I am pasting pipeline YAML here:

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: Npm@1
  displayName: 'npm install'
  inputs:
    command: install
    workingDir: Client

- task: Npm@1
  displayName: 'Build Angular'
  inputs:
    command: custom
    customCommand: run build -- --prod
    workingDir: Client

- task: PublishPipelineArtifact@0
  inputs:
    artifactName: 'angular'
    targetPath: 'Client/dist'

Please help.

2 Answers 2

1

Your first task must be install Angular CLI.

- task: Npm@1
  displayName: angular/cli
  inputs:
    command: custom
    workingDir: Client
    verbose: false
    customCommand: 'install @angular/cli -g'

Can you try running it to the first step?

Sign up to request clarification or add additional context in comments.

1 Comment

-g returned permission error. So, I tried installing it locally by removing -g: - task: Npm@1 displayName: angular/cli inputs: command: custom workingDir: Client verbose: false customCommand: 'install @angular/cli' Above worked fine but the error remains the same.
-1

I was able to get it working after discussion with Microsoft support guys. Here is direct link to solution

Thanks for your support!

1 Comment

The link no longer works. It's fine to have links as a reference in your solution, but the answer should actually be documented in the solution, precisely because links eventually rot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.