1

I run into a problem when installing gatsby plugins.

My Setup:

npm install -g gatsby-cli
gatsby new my-app
gatsby develop

When I try to install a plugin from the Gatsby library im getting this error message after installing the plugin:

Error: Invalid hook call. Hooks can only be called inside of the bo dy of a function component. This could happen for one of the follow ing reasons:

  1. You might have mismatching versions of React and the renderer (s uch as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See fb.me/react-invalid-hook-call for tips about how to deb ug and fix this problem.

Is there something wrong with my dep tree?

├─┬ gatsby@2.23.10
│ └─┬ gatsby-cli@2.12.50
│   └── react@16.13.1  deduped
└── react@16.13.1 
Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67
paddydev
  • 13
  • 2
  • This is not an error due to plugins installation, is because of the usage of the hooks. Can you provide some code to see how are they implemented? – Ferran Buireu Jun 29 '20 at 14:42
  • What code do you want to see? I havent pushed it to Github yet. Basically just done the quick start installation from the Gatsby docs. – paddydev Jun 29 '20 at 14:45
  • Then show your `gatsby-config.js`. Try removing `node_modules` and `.cache` folder and install your dependencies again. – Ferran Buireu Jun 29 '20 at 14:50
  • @FerranBuireu Can I use: npm install -g gatsby-cli gatsby new my-app to install the dependencies again? – paddydev Jun 29 '20 at 14:59
  • `npm install -g gatsby-cli` installs the Gatsby client. You need to remove the `/node_modules` folder inside `my-app` and `.cache` – Ferran Buireu Jun 29 '20 at 15:01
  • @FerranBuireu Okay, Ive removed them now, should I install the gatsby client now again? – paddydev Jun 29 '20 at 15:02
  • The Gatsby client is global! You have already installed. You only need to remove the dependencies inside your project, not outside. Just remove `/node_modules` and `.cache` folders and run the project again. – Ferran Buireu Jun 29 '20 at 15:15
  • @FerranBuireu so, after deleting /node_modules and .cache , I just have to type gatsby develop? – paddydev Jun 29 '20 at 15:28
  • That's my guess, yes. – Ferran Buireu Jun 29 '20 at 15:31
  • @FerranBuireu getting this error now: There was a problem loading the local develop command. Gatsby may not be installed in your site's "node_modules" directory. Perhaps you need to run "npm install"? You might need to delete your "package-lock.json" as well. – paddydev Jun 29 '20 at 15:33
  • @FerranBuireu Its working, thank you!!! – paddydev Jun 29 '20 at 15:38
  • I've added an answer. I'm glad to help. – Ferran Buireu Jun 29 '20 at 15:46

1 Answers1

0

According to the comments above the solution was:

Removing node_modules and .cache folder, reinstalling dependencies via npm install and gatsby develop.

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67