Issue
I have configured Azure DevOps CI pipe for Angular 13 WEB APP. The Node version is 14.17 and NPM 6.14.13 used azure agent Ubuntu 20.04 LTS. Below you can see what I included to my build
resources:
repositories:
- repository: self
type: git
ref: refs/heads/development
jobs:
- job: Job_1
displayName: Agent job 1
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
- task: NodeTool@0
displayName: Use Node 14.17.x
inputs:
versionSpec: 14.17.x
- task: CmdLine@2
displayName: Install Anguler
inputs:
script: npm install -g @angular/cli
- task: Npm@1
displayName: npm install
inputs:
verbose: false
- task: CmdLine@1
displayName: Run ng
inputs:
filename: ng
arguments: build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: dist
ArtifactName: dist
The problem is when it comes to npm install returning following errror
2022-07-05T08:50:59.0085431Z npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
2022-07-05T08:50:59.0086707Z npm ERR! code ERESOLVE
2022-07-05T08:50:59.0087276Z npm ERR! ERESOLVE could not resolve
2022-07-05T08:50:59.0087839Z npm ERR!
2022-07-05T08:50:59.0088385Z npm ERR! While resolving: ng-select2@1.4.1
2022-07-05T08:50:59.0089028Z npm ERR! Found: select2@4.1.0-rc.0
2022-07-05T08:50:59.0089656Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0090324Z npm ERR! select2@"^4.1.0-rc.0" from the root project
2022-07-05T08:50:59.0091059Z npm ERR!
2022-07-05T08:50:59.0091557Z npm ERR! Could not resolve dependency:
2022-07-05T08:50:59.0092182Z npm ERR! peer select2@"^4.0.x" from ng-select2@1.4.1
2022-07-05T08:50:59.0092812Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0093479Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0094043Z npm ERR!
2022-07-05T08:50:59.0094606Z npm ERR! Conflicting peer dependency: select2@4.0.13
2022-07-05T08:50:59.0095230Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0095824Z npm ERR! peer select2@"^4.0.x" from ng-select2@1.4.1
2022-07-05T08:50:59.0096597Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0097203Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0097691Z npm ERR!
2022-07-05T08:50:59.0098212Z npm ERR! Fix the upstream dependency conflict, or retry
2022-07-05T08:50:59.0098870Z npm ERR! this command with --force, or --legacy-peer-deps
2022-07-05T08:50:59.0099604Z npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
2022-07-05T08:50:59.0102846Z npm ERR!
2022-07-05T08:50:59.0103438Z npm ERR! See C:\npm\cache\eresolve-report.txt for a full report.
2022-07-05T08:50:59.0103769Z
2022-07-05T08:50:59.0104331Z npm ERR! A complete log of this run can be found in:
2022-07-05T08:50:59.0105127Z npm ERR! C:\npm\cache\_logs\2022-07-05T08_50_56_733Z-debug-0.log
2022-07-05T08:50:59.1265632Z ##[warning]Couldn't find a debug log in the cache or working directory
2022-07-05T08:50:59.1289161Z ##[error]Error: Npm failed with return code: 1
2022-07-05T08:50:59.1322525Z ##[section]Finishing: npm install
Can anyone help me on this?
Solution
This has nothing to do with the Azure DevOps CI pipeline per se. You have a problem with https://nodejs.org/en/blog/npm/peer-dependencies. In summary, an upstream package relies on a supporting package being installed downstream by the hosting application and versions can be quite restricted. The workaround (as per the error message) is to use npm install --legacy-peer-deps
https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps . You can find out what the peer dependencies for a package are by using the command npm info ng-select2 peerDependencies
or specific version npm info ng-select2@1.4.1 peerDependencies
.
Result below. Notice that ng-select2@1.4.1
relies on select2@^4.0.x
.
Have you installed select2@^4.0.x
?
{
'@angular/common': '^13.0.0',
'@angular/core': '^13.0.0',
'@types/jquery': '3.5.x',
'@types/select2': '^4.0.x',
select2: '^4.0.x',
jquery: '3.5.x'
}
Installing the correct version of npm install select2@^4.0.0
should solve your problem.
In your package.json
:
"select2": "^4.0.0"
Answered By - Robin Webb
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.