devryan
devryan

Reputation: 31

Error when trying to install a gatsby plugin

When trying to install plugin-gatsby-react-helment getting the following error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/gatsby
npm ERR!   gatsby@"^3.11.1" from the root project
npm ERR!
npm ERR! peer gatsby@"^4.0.0-next" from [email protected]
npm ERR! node_modules/gatsby-plugin-react-helmet
npm ERR!   gatsby-plugin-react-helmet@"*" 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!
npm ERR! See C:\Users\Asus\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\Asus\AppData\Local\npm-cache\_logs\2021-12-24T14_44_33_845Z-debug.log

but react-helmet just install fine I am clueless

Upvotes: 1

Views: 2119

Answers (2)

Rahul
Rahul

Reputation: 1

I faced the same error recently. Here's how you can fix it

  1. Delete package-lock.json
  2. Goto gatsby folder path and run gatsby develop or run npm i

If it doesn't work, delete node modules and try the above steps again

Upvotes: 0

Ferran Buireu
Ferran Buireu

Reputation: 29320

It's quite self-explanatory.

You have installed a Gatsby version ^3.11.1 as it is extracted from:

npm ERR!   gatsby@"^3.11.1" from the root project

While gatsby-plugin-react-helmet as is, without a specific version tries to install the latest one (5.4.0). This latest version requires a Gatbsby version 4 onwards (major update) as it is extracted from:

npm ERR! peer gatsby@"^4.0.0-next" from [email protected]
npm ERR! node_modules/gatsby-plugin-react-helmet
npm ERR!   gatsby-plugin-react-helmet@"*" from the root project

That said, depending on your specifications you have two options:

The second one will have a lower impact in your project but ideally, sooner or later you will need to upgrade the Gatsby version.

I guess, being a lower major update any version 4 of the gatsby-plugin-react-helmet plugin should work. If not, try lowering the version.

Remember to clean the cache (with gatsby clean) in each trial.

Upvotes: 2

Related Questions