Common Gatsby Initial Install <br> and Plugin Install Errors

Let’s go!

Ever try to install a new Gatsby plugin and get hit with an error message? Or try to start a new Gatsby project with a theme and have it fail? Well here is a set of steps you can try and take to solve it. It’s not issue specific, so you probably don’t need all the steps listed here. Often you can skip most of them and just try one. Regardless, here is a good starting point towards solving your issue.

Make sure everything is up to date

Run gatsby info --clipboard and double check to make sure everything is the latest version. Having an old version of Node, npm, or obviously Gatsby can cause issues.

To update Node first install n, and pick either the latest or stable to update to.

npm cache clean -f
sudo npm install n -g
sudo n stable
sudo n latest

To update npm:

sudo npm install -g npm@latest

To update Gatsby, first run npm outdated and if it needs to be updated put the latest version inside your package.json file:

"dependencies": {
    "@mdx-js/mdx": "^1.6.6",
    "@mdx-js/react": "^1.6.6",
    "gatsby": "^2.23.12",
}

After that run npm update

Delete

Now that everything is up to date, if it is still not working the next step is to delete your node_modules folder and package-lock.json file from your Gatsby project. Once those are deleted you can delete the cache and run npm install:

sudo npm cache clean --force
npm install

Or yarn instead of npminstall if you use yarn as your package manager.

This will reinstall all your dependencies. Try running gatsby develop after and see if your project works.