3

I am trying to do CI/CD with Azure devops and the below task is failing.

Here is the package.json file info:

"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",

Here is the error message:

Error message enter image description here

I have tried removing --prod, creating a custom build argument, and editing the Yaml to manually call ng build

Robert
  • 4,306
  • 11
  • 45
  • 95
  • Maybe there is an issue with the angular cli... maybe try `npm run build` and see if that works? – Zze Oct 22 '19 at 23:16
  • The message says it can’t find the angular-devkit/build-angular module in line 32. Is that pointing to the correct location? It seems like that might cause an issue with the build process. – Alex Morales Oct 23 '19 at 03:11
  • is says in the error log that your missing 'node_modules', which means you needs to run `npm install` before the build step – Sebastian Scholle Feb 10 '22 at 07:03

2 Answers2

4

In your environment the following npm and node versions are set:

npm 6.9.0
node 10.16.3

There is an issue, that npm doesn't support this node.js version: https://github.com/nodejs/help/issues/2134.

To fix that you need to add 'Node.js tool installer' task to settle node.js version to supported 8.11.2 (or check which version you use) one, before npm install task in your pipeline: enter image description here

Anna
  • 2,988
  • 3
  • 15
  • 29
  • Please updated your question with pipeline steps. It should be like: 1. Install Node. 2 npm install. 3. npm install -g @angular/cli 4. ng build --prod (this step gives you dist folder) 5. Copy dist folder to artifactstagingdirectory 6. Publish Artifact – Anna Oct 23 '19 at 23:35
  • Also what npm, node and angular versions you use? – Anna Oct 23 '19 at 23:39
  • Check [node.js](https://nodejs.org/en/download/releases/) site to help you with versions – Anna Oct 24 '19 at 05:33
  • Failing for me even after following above steps – Techiemanu Oct 17 '20 at 22:25
1

Why is ng build failing on azureDevOps?

There is known issue about this issue on the github:

Module build failed error when run ' ng build prod'

And this issue was originally reported a long time ago and since then we've had many releases, one of which might have addressed this problem. Please update to the most recent Angular CLI version.

So, please try to update the Angular CLI version on the agent:

npm uninstall -g angular-cli
npm cache clean or npm cache verify #(if npm > 5)
npm install -g @angular/cli@latest

Check this thread for some more details.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135