How to fix dependency issue during package installation?

28 Views Asked by At

I'm trying to install CRACO in the project. I currently have "typescript": "^5.3.2" installed. When I try to install CRACO I get error:

npm i -D @craco/craco                     
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"*" from @storybook/[email protected]
npm ERR!   node_modules/@storybook/react
npm ERR!     @storybook/react@"7.5.3" from @storybook/[email protected]
npm ERR!     node_modules/@storybook/nextjs
npm ERR!       dev @storybook/nextjs@"^7.0.22" from the root project
npm ERR!     @storybook/react@"7.5.3" from @storybook/[email protected]
npm ERR!     node_modules/@storybook/preset-react-webpack
npm ERR!       @storybook/preset-react-webpack@"7.5.3" from @storybook/[email protected]
npm ERR!       node_modules/@storybook/nextjs
npm ERR!         dev @storybook/nextjs@"^7.0.22" from the root project
npm ERR!     1 more (the root project)
npm ERR!   peer typescript@">= 4.x" from @storybook/[email protected]
npm ERR!   node_modules/@storybook/react-docgen-typescript-plugin
npm ERR!     @storybook/react-docgen-typescript-plugin@"1.0.6--canary.9.0c3f3b7.0" from @storybook/[email protected]
npm ERR!     node_modules/@storybook/preset-react-webpack
npm ERR!       @storybook/preset-react-webpack@"7.5.3" from @storybook/[email protected]
npm ERR!       node_modules/@storybook/nextjs
npm ERR!         dev @storybook/nextjs@"^7.0.22" from the root project
npm ERR!   11 more (eslint-config-next, fork-ts-checker-webpack-plugin, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from [email protected]
npm ERR! node_modules/react-scripts
npm ERR!   peer react-scripts@"^5.0.0" from @craco/[email protected]
npm ERR!   node_modules/@craco/craco
npm ERR!     dev @craco/craco@"*" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1 || ^4" from [email protected]
npm ERR!   node_modules/react-scripts
npm ERR!     peer react-scripts@"^5.0.0" from @craco/[email protected]
npm ERR!     node_modules/@craco/craco
npm ERR!       dev @craco/craco@"*" 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.

At the CRACO package I found devDependency "typescript": "^4.8.4", which ideally shouldn't cause problems, since my typescript is newer. So why is it complaining? I can try and force installation or use --legacy-peer-deps, but I'm not sure if this is the best solution.

0

There are 0 best solutions below