node.jsexpressdependenciessinonsinon-chai

Unresolved dependency while upgrading project setup from v16 to v20.9.0 for sinon-chai package


I am using node v16.14.2 for my existing project. wanted to upgrad to v20 LTS. I have set node version to 20.9.0. and tried npm install, and got below mentione error.


npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: sinon-chai@2.14.0
npm ERR! Found: sinon@6.1.3
npm ERR! node_modules/sinon
npm ERR!   dev sinon@"6.1.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer sinon@"^1.4.0 || ^2.1.0 || ^3.0.0 || ^4.0.0" from sinon-chai@2.14.0
npm ERR! node_modules/sinon-chai
npm ERR!   dev sinon-chai@"^2.8.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: sinon@4.5.0
npm ERR! node_modules/sinon
npm ERR!   peer sinon@"^1.4.0 || ^2.1.0 || ^3.0.0 || ^4.0.0" from sinon-chai@2.14.0
npm ERR!   node_modules/sinon-chai
npm ERR!     dev sinon-chai@"^2.8.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.
npm ERR!

I tried upgrading specific package but no luck. sinon-chai is last updated 3 years ago, Is there any other relavent package which can solve this problem or any other solution to this.


Solution

  • sinon-chai 3.2.0 added support for Sinon 6.x, see sinon-chai/releases/tag/v3.2.0

    You should update the sinon-chai from ^2.8.0 to ^3.2.0

    The peer dependencies of sinon-chai@3.2.0:

    $ npm view sinon-chai@3.2.0 peerDependencies
    { chai: '^4.0.0', sinon: '>=4.0.0 <7.0.0' }
    

    The peer dependencies of sinon-chai@2.14.0:

    $ npm view sinon-chai@2.14.0 peerDependencies
    { chai: '>=1.9.2 <5', sinon: '^1.4.0 || ^2.1.0 || ^3.0.0 || ^4.0.0' }