I´m trying to remake an Angular Workspace including my library project and a test application using Angular 11 but if I´ve installed @angular/[email protected]
when I run
ng new my-workspace-v11 --create-application false
I got this package.json
{
"name": "my-workspace-v11",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.1.1",
"@angular/common": "~11.1.1",
"@angular/compiler": "~11.1.1",
"@angular/core": "~11.1.1",
"@angular/forms": "~11.1.1",
"@angular/platform-browser": "~11.1.1",
"@angular/platform-browser-dynamic": "~11.1.1",
"@angular/router": "~11.1.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular/cli": "~11.1.2",
"@angular/compiler-cli": "~11.1.1",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.2.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.2"
}
}
And I got an error with jasmine-core. So, as I´m using this library for specific angular projects and I need that works for them, I would like to get a workspace with :
...
"@angular/cdk": "^11.0.1",
"@angular/common": "^11.0.3",
"@angular/compiler": "^11.0.3",
"@angular/core": "^11.0.3",
...
And do something to avoid any conflict of packages. What is the process to do that ?
Even if I ask all exactly versions of a specific angular projet which is running on production server, I got building error.
I tried this :
{
"name": "my-workspace-v11",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "11.0.3",
"@angular/cdk": "11.0.1",
"@angular/common": "11.0.3",
"@angular/compiler": "11.0.3",
"@angular/core": "11.0.3",
"@angular/forms": "11.0.3",
"@angular/platform-browser": "11.0.2",
"@angular/platform-browser-dynamic": "11.0.2",
"@angular/router": "11.0.2",
"rxjs": "6.4.0",
"tslib": "1.10.0",
"zone.js": "0.9.1"
},
"devDependencies": {
"@angular/cli": "11.0.2",
"@angular/compiler-cli": "11.0.2",
"@types/jasmine": "3.3.16",
"@types/node": "8.9.5",
"codelyzer": "5.2.1",
"jasmine-core": "3.4.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.6",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.5.1",
"protractor": "5.4.2",
"ts-node": "7.0.1",
"tslint": "5.15.0",
"typescript": "4.0.5"
}
}
I got this :
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/rxjs
npm ERR! rxjs@"6.4.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^6.5.3" from @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"11.0.3" from the root project
npm ERR! peer @angular/core@"11.0.3" from @angular/[email protected]
npm ERR! node_modules/@angular/animations
npm ERR! @angular/animations@"11.0.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
How is it possible ?
CodePudding user response:
Double check that the project you're trying to replicate has the version you're looking for exactly, watching for minor and patch versions
"@angular/core": "11.0.3"
vs
"@angular/core": "^11.0.3"
It's possible that the installed versions will differ from what you're expecting because of the ^
CodePudding user response:
The problem should be when you use a [email protected] or superior
(I´m using [email protected]), peer dependencies can block the install process. These versions are more strict.
To avoid that problem, the command npm install --legacy-peer-deps
makes the job.
In my case, the project using my library was built with a npm 6.x.x, that´s why some package incompatibilties was accepted before and not now.