Questions & Answers

Nestjs Can't Install @t00nday/nestjs-pdf

I was try to install @t00nday/nestjs-pdf using npm, But found error like this

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: server-nestjs@0.0.1
npm ERR! Found: @nestjs/common@9.2.1
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^9.2.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^6.10.0 || ^7.0.0 || ^8.0.0" from @t00nday/nestjs-pdf@3.0.5
npm ERR! node_modules/@t00nday/nestjs-pdf
npm ERR!   @t00nday/nestjs-pdf@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry

I dont want to use command --force or --legacy-peer-deps. I want to try downgrading my nest version but too much peer dependency to change in package.json Anyone know how to fix this ?

Answers(1) :

@t00nday/nestjs-pdf has a peer dependency on @nestjs/common for verion ^6.0.0, ^7.0.0 or ^8.0.0. This means that any @nestjs/common version 6, 7, or 8 compatible version van be installed. By Semver's standards, compatible means non-major version difference (there's more nuance than that but it's enough to think of that for this use case). In your application you have @nestjs/common@9.2.1 installed, which npm reads as non-compatible due to the major difference in the versions.

In reality, Nest version 9 should be compatible with version 8, so you can use --force to get around this if you need. The other option is to drop all of your Nest dependencies down to v8 compatible versions, or fork @t00nday/nestjs-pdf and publish a Nest v9 compatible version or make a PR to update that library for the author and hope it gets merged and published quickly.

2023-01-21 00:25:05
If using --force when install in my local. Should i modified my command when run npm install in my Dockerfile ?
2023-01-21 00:25:05
Most likely, yes. Your docker install should mimic your local install. Or actually, it should be the other way around. Local should mimic docker.