Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby not working after yarn install #23312

Closed
matchatype opened this issue Apr 20, 2020 · 6 comments
Closed

Gatsby not working after yarn install #23312

matchatype opened this issue Apr 20, 2020 · 6 comments
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@matchatype
Copy link

Description

Having a pretty weird issue. My Gatsby app used to run just fine. Today I updated to v2.20.26 using yarn as usual. From that point on, running any command, like gatsby develop returned me this error:

 ERROR 

There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm install"? Cannot find module 'date-fns/getDayOfYear'

I tried gatsby clean , rm -rf node_modules, even rolling back to a previously working app... nothing... Always triggering that error. Then I tried npm install and that's working.

So, after a couple of tests, I noticed that if I clean node_modules and use npm install, everything works. With yarn install it doesn't. Tried also removing package-lock.json and yarn.lock. Nothing seems to help yarn.

If I install via npm and then run any command with yarn, it will work just fine. So apparently there's an issue with yarn install. I'm running yarn v1.22.4 and always worked fine till today.

I tried comparing the contents of the node_modules directory using both package managers (with no lock files) and they actually differ.

@matchatype matchatype added the type: bug An issue or pull request relating to a bug in Gatsby label Apr 20, 2020
@herecydev
Copy link
Contributor

What are the differences you see?

@matchatype
Copy link
Author

matchatype commented Apr 20, 2020

Pretty much every dependency folder has different size, but the most notable issue is that gatsby-cli is completely missing in npm's node_modules directory.

@herecydev
Copy link
Contributor

What version of yarn are you using?

@matchatype
Copy link
Author

yarn v1.22.4
npm v6.13.4
node v12.16.1

@matchatype
Copy link
Author

matchatype commented Apr 21, 2020

What worked in my case was cleaning my cache with yarn cache clean. I read about rather similar issues of people having similar mysterious problems, however with npm rather than yarn, and nobody tried this. Npm has similar feature npm cache clean.

@a-maccormack
Copy link

I checked documentation (https://classic.yarnpkg.com/en/docs/cli/global),
and this is what ended up working for me on Linux (pop-os 21.10):

Add the following line to ~/.bashrc or ~/.zshrc (depending on what you use)

export PATH="$HOME/.yarn/bin:$PATH"

And you're done.

If this doesn't work for you, you can search for your yarn bin directory with the following command:

yarn global bin

Then replace (yarn bin path) on ~/.bashrc or ~/.zshrc with the path you got by using the command above

export PATH="$(yarn bin path):$PATH"

Hope this helps anyone struggling to solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants