我在尝试执行npm install @nestjs/microservices时遇到此错误:
# npm resolution error report
While resolving: [appName]
Found: @nestjs/[email protected]
node_modules/@nestjs/common
@nestjs/common@"^9.4.3" from the root project
Could not resolve dependency:
peer @nestjs/common@"^10.0.0" from @nestjs/[email protected]
node_modules/@nestjs/microservices
@nestjs/microservices@"*" from the root project
Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.
这些是我在 package.json 中的依赖项:
"dependencies": {
"@nestjs/cache-manager": "^2.1.0",
"@nestjs/common": "^9.4.3",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^9.4.3",
"@nestjs/swagger": "^7.0.12",
"@nestjs/typeorm": "^10.0.0",
"bcryptjs": "^2.4.3",
"cache-manager": "^5.2.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"dotenv": "^16.3.1",
"express-session": "^1.17.3",
"jsonwebtoken": "^9.0.0",
"passport": "^0.6.0",
"passport-google-oauth20": "^2.0.0",
"pg": "^8.11.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"typeorm": "^0.3.17"
},
我尝试使用--legacy-peer-deps但它不会编译,我不想使用--force。如果有人知道要解决什么问题,我将非常感激。
您正在尝试安装 v10 NestJS 包,而您的项目中正在使用 v9;您可以安全地安装 @nestjs/microservices 9.4.3
npm install @nestjs/microservices@^9.4.3
或将实际包升级到 v10(可能必须对代码进行一些更改)。