1
votes

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?

├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected] 
1
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
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
Then show your gatsby-config.js. Try removing node_modules and .cache folder and install your dependencies again.Ferran Buireu
@FerranBuireu Can I use: npm install -g gatsby-cli gatsby new my-app to install the dependencies again?paddydev
npm install -g gatsby-cli installs the Gatsby client. You need to remove the /node_modules folder inside my-app and .cacheFerran Buireu

1 Answers

0
votes

According to the comments above the solution was:

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