Reputation: 3
task: NodeTool@0 inputs: versionSpec: '16.14' displayName: 'Install Node.js 16'
script: | npm install -g @angular/cli cd Frontend/Frontend npm install -g npm@latest npm cache clean --force npm rm -rf node_modules && rm package-lock.json npm install npm install --force displayName: 'Install Angular CLI and Node.js dependencies'
script: ng build --prod displayName: 'Build Angular app' workingDirectory: cd Frontend/Frontend
script: | npm test displayName: 'Run Node.js tests'
how to solve this, i want to build the angular with nodejs, during that it throughs this error
Upvotes: 0
Views: 2607
Reputation: 8195
If you want to build the node app with Azure DevOps pipeline, given your code is in Azure repository, You need to make use of predefined variable below:-
$(System.DefaultWorkingDirectory)
When I used my repository name directly without the predefined variable above, I received the same error code, Refer below:-
I used the $(System.DefaultWorkingDirectory)
that will read the source code from my Azure repository, As I directly have my app in the repository, without any directory structure like Frontend/Frontend I only used $(System.DefaultWorkingDirectory)
variable as working directory. In your case if you have a Frontend app inside a Frontend Folder, Add
$(System.DefaultWorkingDirectory)/Frontend
> $(System.DefaultWorkingDirectory)
is your repository which will read Frontend folder, Specify the internal Frontend folder with /
.
My Azure repository:-
My YAML file:-
trigger:
branches:
include:
- master
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: |
npm install -g @angular/cli
npm install
ng build
displayName: 'npm install and build'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- script: |
npm install -g @angular/cli
cd Frontend/Frontend
npm install -g npm@latest
npm cache clean --force
npm rm -rf node_modules && rm package-lock.json
npm install
displayName: 'Install Angular CLI and Node.js dependencies'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- script: |
ng build
displayName: 'Build Angular app'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- script: |
npm test
displayName: 'Run Node.js tests'
workingDirectory: '$(System.DefaultWorkingDirectory)'
#
Output:-
Upvotes: 0