gab*_*har 10 dependencies node.js npm angular
我已经创建了这个 Angular 库,现在我想在其他 Angular 应用程序中使用它,但我似乎在对等依赖项方面遇到了麻烦。我尝试在我的应用程序的 package.json 中摆弄,但似乎无法消除任何错误。
我尝试过的(按顺序):
以下是错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: lib-test@0.0.0
npm ERR! Found: @angular/common@13.0.3
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"~13.0.0" from the root project
npm ERR! peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.2.2
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"^13.2.0" from the root project
npm ERR! peer @angular/cdk@"^13.0.0" from @my-group/angular-lib@1.1.4
npm ERR! node_modules/@my-group/angular-lib
npm ERR! @my-group/angular-lib@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^13.1.0" from @my-group/angular-lib@1.1.4
npm ERR! node_modules/@my-group/angular-lib
npm ERR! @my-group/angular-lib@"*" 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.
Run Code Online (Sandbox Code Playgroud)
package.json(应用程序)
{
"name": "lib-test",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.0.0",
"@angular/cdk": "^13.2.2",
"@angular/common": "~13.0.0",
"@angular/compiler": "~13.0.0",
"@angular/core": "~13.0.0",
"@angular/forms": "~13.0.0",
"@angular/material": "^13.2.2",
"@angular/platform-browser": "~13.0.0",
"@angular/platform-browser-dynamic": "~13.0.0",
"@angular/router": "~13.0.0",
"@cloud-republic/angular-lib": "^1.1.4",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.0.3",
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.4.3"
}
}
Run Code Online (Sandbox Code Playgroud)
package.json(库)
{
"name": "@my-group/angular-lib",
"version": "1.0.6",
"publishConfig": {
"@my-group:registry": "https://gitlab.com/api/v4/projects/XXXXXX/packages/npm/"
},
"scripts": {
"build-lib": "ng build lib-angular",
"semantic-release": "semantic-release"
},
"peerDependencies": {
"@angular/cdk": "^13.0.0",
"@angular/common": "^13.1.0",
"@angular/core": "^13.1.0",
"@angular/material": "^13.2.0",
"ngx-bootstrap": "^8.0.0",
"rxjs": "~7.4.0"
},
"dependencies": {
"tslib": "^2.3.0"
},
"devDependencies": {
"@semantic-release/gitlab": "^7.0.4",
"semantic-release": "^19.0.2"
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
Vim*_*tel 26
这不是对等依赖性的问题。这更多地与版本冲突有关。我猜您正在使用 npm >=7 这就是您收到此错误的原因:-
如错误日志中所述,请尝试以下命令来解决问题:-
npm install --legacy-peer-deps
Run Code Online (Sandbox Code Playgroud)
上述解决方案将解决您的问题。但是,主要问题在于您的图书馆。在您的库包中,您说使用以下包:-
"@angular/common": "^13.1.0"
Run Code Online (Sandbox Code Playgroud)
但是,在您的应用程序中,您安装了以下版本。“@Angular/common”:“~13.0.0”。所以你的库包比应用程序中安装的库包大。在您的应用程序中安装相同的版本或降级您的库中的版本。
这样,npm install命令就可以正常工作。
| 归档时间: |
|
| 查看次数: |
38017 次 |
| 最近记录: |