'deprecated errors while installing packagesin gastby

I am using a Gatsby theme and facing this errors while installing packages , I've tried npm install --legacy-peer-deps but when I run gatsby develop I get the errors again : this is the errors I am facing :

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/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@"15.x || 16.x || 17.x" from @gatsbyjs/[email protected]
npm ERR!   node_modules/@gatsbyjs/reach-router
npm ERR!     @gatsbyjs/reach-router@"^1.3.6" from [email protected]
npm ERR!     node_modules/gatsby
npm ERR!       gatsby@"^4.4.0" from the root project
npm ERR!       12 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     peer @gatsbyjs/reach-router@"^1.3.5" from [email protected]
npm ERR!     node_modules/gatsby-link
npm ERR!       gatsby-link@"^4.6.0" from [email protected]
npm ERR!       node_modules/gatsby
npm ERR!         gatsby@"^4.4.0" from the root project
npm ERR!         12 more (babel-plugin-remove-graphql-queries, ...)
npm ERR!     1 more (gatsby-react-router-scroll)
npm ERR!   18 more (@loadable/component, gatsby, gatsby-link, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from [email protected]
npm ERR! node_modules/react-owl-carousel3
npm ERR!   react-owl-carousel3@"^2.2.5" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from [email protected]
npm ERR!   node_modules/react-owl-carousel3
npm ERR!     react-owl-carousel3@"^2.2.5" from the root project
npm ERR!
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 C:\Users\foxxp\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\foxxp\AppData\Local\npm-cache\_logs\2022-05-04T23_14_25_607Z-debug-0.log

It seems there lot of deprecated versions How Can i fix this please ??



Solution 1:[1]

Try:

  • Remove your node_modules
  • Install the (peer) dependencies again with:
    npm install --legacy-peer-deps
    
  • Start the development process again with:
    gatsby develop
    

If the issue persists remove your package-lock.json file and redo all the processes above.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1