I try to update my Nestjs Backend and have dependency conflicts. Unfortunately I can't figure out what the cause is. I have already updated mongoose and also updated NestJS to the latest version.
ERROR:
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/mongoose
npm ERR! mongoose@"6.5.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mongoose@"5.10.0 - 5.10.18" from @typegoose/[email protected]
npm ERR! node_modules/@typegoose/typegoose
npm ERR! @typegoose/typegoose@"^7.4.8" 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!
npm ERR! See /Users/XX/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/XX/.npm/_logs/2022-08-07T19_52_18_976Z-debug-0.log
package.json
{
"name": "server",
"version": "0.0.2",
"description": "",
"author": "",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^9.0.8",
"@nestjs/core": "^9.0.8",
"@nestjs/jwt": "^9.0.0",
"@nestjs/mongoose": "^9.2.0",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.8",
"@typegoose/typegoose": "^7.4.8",
"axios": "^0.27.2",
"bcrypt": "^5.0.1",
"mongoose": "6.5.1",
"nestjs-typegoose": "^7.1.38",
"passport": "^0.6.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.6.2",
"rxjs": "^7.5.6"
},
"devDependencies": {
"@nestjs/testing": "^9.0.8",
"@types/express": "^4.16.0",
"@types/jest": "^23.3.13",
"@types/mongoose": "^5.5.6",
"@types/node": "^10.12.18",
"@types/supertest": "^2.0.7",
"concurrently": "^7.3.0",
"jest": "^28.1.3",
"nodemon": "^2.0.19",
"prettier": "^1.15.3",
"supertest": "^3.4.1",
"ts-jest": "^28.0.7",
"ts-node": "8.1.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"wait-on": "^3.2.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^. \\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
It is a NestJS backend with Mongoose. Unfortunately, I can't make sense of the error message
Thank you!
CodePudding user response:
Upgrade @typegoose/typegoose
to its latest version (v9)
$ npm view @typegoose/typegoose@7 peerDependencies
@typegoose/[email protected] { mongoose: '^5.9.10', '@types/mongoose': '^5.7.12' }
@typegoose/[email protected] { mongoose: '^5.9.14', '@types/mongoose': '^5.7.19' }
@typegoose/[email protected] { mongoose: '^5.9.14', '@types/mongoose': '^5.7.19' }
@typegoose/[email protected] { mongoose: '^5.9.14', '@types/mongoose': '^5.7.20' }
@typegoose/[email protected] { mongoose: '^5.9.14', '@types/mongoose': '^5.7.20' }
@typegoose/[email protected] { mongoose: '^5.9.17', '@types/mongoose': '^5.7.21' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.9.22', '@types/mongoose': '^5.7.30' }
@typegoose/[email protected] { mongoose: '^5.10.4', '@types/mongoose': '^5.7.36' }
@typegoose/[email protected] { mongoose: '^5.10.4', '@types/mongoose': '^5.7.36' }
@typegoose/[email protected] { mongoose: '^5.10.4', '@types/mongoose': '^5.7.36' }
@typegoose/[email protected] { mongoose: '5.10.0 - 5.10.18', '@types/mongoose': '^5.10.1' }
@typegoose/[email protected] { mongoose: '5.10.0 - 5.10.18', '@types/mongoose': '^5.10.1' }
@typegoose/[email protected] { mongoose: '5.10.0 - 5.10.18', '@types/mongoose': '^5.10.2' }
@typegoose/[email protected] { mongoose: '5.10.0 - 5.10.18', '@types/mongoose': '^5.10.2' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '^5.10.2', mongoose: '5.10.0 - 5.10.18' }
@typegoose/[email protected] { '@types/mongoose': '~5.10.2', mongoose: '5.10.0 - 5.10.18' }
as you can see above, v7 requires mongoose
v5 (but you have v6 installed).
$ npm view @typegoose/typegoose peerDependencies
{ mongoose: '~6.5.0' }