Skip to content
New issue

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

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

Already on GitHub? # to your account

yarn global add create-react-app doesn’t work with nvm #1118

Closed
stevensacks opened this issue Nov 30, 2016 · 12 comments
Closed

yarn global add create-react-app doesn’t work with nvm #1118

stevensacks opened this issue Nov 30, 2016 · 12 comments

Comments

@stevensacks
Copy link

At the request of @gaearon:

https://yarnpkg.com/en/docs/cli/global

The official Yarn documentation states that you can install (and maintain) your create-react-app project with yarn. However, it doesn't actually work. Calling create-react-app after a global yarn install does nothing. CRA currently only works from a global npm install.

It would be great if yarn and CRA went together like chocolate and peanut butter.

@gaearon
Copy link
Contributor

gaearon commented Nov 30, 2016

Works for me:

gaearon@gaearon-mbp ~> yarn global add create-react-app
Using globally installed version of Yarn
yarn global v0.17.8
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed create-react-app@0.6.0 with binaries:
      - create-react-app
warning No license field
✨  Done in 2.99s.

gaearon@gaearon-mbp ~> create-react-app ~/p/hmmm
Creating a new React app in /Users/gaearon/p/hmmm.

Installing packages. This might take a couple minutes.
Installing react-scripts from npm...

Can you specify more details?

@stevensacks
Copy link
Author

stevensacks commented Nov 30, 2016 via email

@gaearon
Copy link
Contributor

gaearon commented Nov 30, 2016

I'm using a FB laptop so it's preinstalled here. I'll try again at home.

@existentialism
Copy link
Contributor

existentialism commented Nov 30, 2016

I was able to repro this...

Initial setup:
yarn@0.17.8 (installed via npm)
node@6.9.1 (installed via nvm)

Switched to node 4 via nvm, yarn global add create-react-app, and got:

-bash: create-react-app: command not found

@stevensacks this at all similar to your situation? If you do a global remove, then global add, does it work?

Likely related to yarnpkg/yarn#1151 (comment)?

@newswim
Copy link

newswim commented Dec 1, 2016

perhaps try installing with brew, as per this guide?

@stevensacks
Copy link
Author

stevensacks commented Dec 1, 2016 via email

@gaearon
Copy link
Contributor

gaearon commented Dec 5, 2016

Maybe I can't reproduce because I'm using n instead of nvm.
Will need to try with nvm.

@gaearon gaearon changed the title Yarn integration yarn global add create-react-app doesn’t work Dec 5, 2016
@gaearon gaearon changed the title yarn global add create-react-app doesn’t work yarn global add create-react-app doesn’t work with nvm Dec 5, 2016
@guilhermecvm
Copy link

@stevensacks why would be not recommended to use brew?

@shubheksha
Copy link
Contributor

I can reproduce this as well. Installed Yarn via npm and node via npm. Also doesn't work for node installed via brew.

@gaearon
Copy link
Contributor

gaearon commented Dec 13, 2016

Likely yarnpkg/yarn#1151, we need to wait for this to be fixed on Yarn side.
I'm already tracking all Yarn issues in #1189 so I'll close this one as it's unactionable for us.

@gaearon gaearon closed this as completed Dec 13, 2016
@zegilooo
Copy link

This solved it for me (on Ubuntu 16.04)
export PATH=$PATH:~/.yarn/bin

@kushalj
Copy link

kushalj commented Jan 28, 2018

Hi, so this looks like a chain of crappy bugs cluster-munging together... For me I think it's the result of using NVM and Yarn together which might be confusing Yarn a little.

I deleted my yarn (I'm on Ubuntu on this laptop) and reinstalled using "don't give me extra things"

sudo apt-get remove yarn
sudo apt-get install --no-install-recommends yarn

Then found that yarn global bin is /usr/local/bin but the actual location is ~/.config/yarn/global/node_modules/.bin or something.

Yarn may not fix this for NVM anytime soon but this NPM utility shortcuts the manual file linking:

https://www.npmjs.com/package/fix-yarn-global-packages

(not my tool, just just found it looking around)

I then tested location using which create-react-app which gave me /usr/local/bin/create-react-app, finally!

This:
yarn create react-app <name> --scripts-version reason-scripts
then worked and chugged away happily building the app.

@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

8 participants