我通过 angular cli 创建了一个新的 angular 项目,当我尝试通过ng add apollo-angular
命令添加 apollo angular 时出现以下错误
The package apollo-angular@2.6.0 will be installed and executed.
Would you like to proceed? Yes
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: angular-graphql-sample@0.0.0
npm ERR! Found: @angular/core@13.2.2
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"~13.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^6.1.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0" from apollo-angular@2.6.0
npm ERR! node_modules/apollo-angular
npm ERR! apollo-angular@"2.6.0" 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.
我不确定这是否是因为角度版本。我正在使用的版本如下所示。
Angular CLI: 13.2.3
Node: 16.13.2
Package Manager: npm 8.4.1
OS: win32 x64
Angular: 13.2.2
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1302.3
@angular-devkit/build-angular 13.2.3
@angular-devkit/core 13.2.3
@angular-devkit/schematics 13.2.3
@angular/cli 13.2.3
@schematics/angular 13.2.3
rxjs 7.5.4
typescript 4.5.5
我尝试使用 npm install apollo-angular @apollo/client
graphql 但同样的问题。
我也尝试卸载并再次安装,但没有运气。
谁能帮我解决这个问题?提前致谢。我正在添加我的package.json
.
{
"name": "angular-graphql-sample",
"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.2.0",
"@angular/common": "~13.2.0",
"@angular/compiler": "~13.2.0",
"@angular/core": "~13.2.0",
"@angular/forms": "~13.2.0",
"@angular/platform-browser": "~13.2.0",
"@angular/platform-browser-dynamic": "~13.2.0",
"@angular/router": "~13.2.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.2.3",
"@angular/cli": "~13.2.3",
"@angular/compiler-cli": "~13.2.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.5.2"
}
}