Gatsby, fix "Cannot find module gatsby-cli/lib/reporter" error

How can I fix the weird error: Cannot find module gatsby-cli/lib/reporter error when creating Gatsby website

I created a website usingGatsbyThen i rangatsby developStart the local server.

But a strange error occurred and my terminal was displayed in red:

Gatsby error

After a few searches on GitHub and StackOverflow (I found that many people have the same problem!), this is the reason for fixing the error.

First, I deletednode_modules:

rm -rf node_modules

then I used yarn instead of npm install:

yarn

This installed all the packages again.

Finally I ran gatsby develop and it worked.

Not sure what the cause problem is/was, but I tried again running npm install instead of yarn and it didn’t work.


More js tutorials: