In the process of learning nest.js, I've run into an npm dependency tree issue.
I'm attempting to do something like npm install --save-dev @types/bcrypt @types/passport @types/passport-jwt. This (and similar npm commands) will throw this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @nestjs/passport@8.2.1
npm ERR! Found: passport@0.6.0
npm ERR! node_modules/passport
npm ERR! passport@"^0.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer passport@"^0.4.0 || ^0.5.0" from @nestjs/passport@8.2.1
npm ERR! node_modules/@nestjs/passport
npm ERR! @nestjs/passport@"^8.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: passport@0.5.3
npm ERR! node_modules/passport
npm ERR! peer passport@"^0.4.0 || ^0.5.0" from @nestjs/passport@8.2.1
npm ERR! node_modules/@nestjs/passport
npm ERR! @nestjs/passport@"^8.2.1" 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.
I've traced the problem to the following:
- I currently have version 8.2.1 of @nestjs/passport installed - this was released on Feb 16
- I can see in my local folder of node_modules/@nestjs/passport/package.json that it has the dependency
"passport": "^0.4.0 || ^0.5.0, as the terminal error implies - In the current Github version of @nestjs/passport, however, I see that they've updated that line to include
|| ^0.6.0in late May link
@nestjs/passport hasn't created a new release with this (and other) updates yet though.
Two things I'm wondering:
- How can I resolve this dependency issue now, before the maintainers of @nestjs/passport publish their next release?
- Why doesn't it work for me to go into my local node_modules/@nestjs/passport/package.json file and manually change it to include ^0.6.0? (After doing that, saving the file, and trying the npm commands again, I still get the same dependency errors)