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

Document how to install yarn when you use nvm #3255

Closed
binarykitchen opened this issue Apr 25, 2017 · 28 comments · Fixed by yarnpkg/website#516
Closed

Document how to install yarn when you use nvm #3255

binarykitchen opened this issue Apr 25, 2017 · 28 comments · Fixed by yarnpkg/website#516

Comments

@binarykitchen
Copy link
Contributor

I have a mess here on my both machines, running on Ubuntu and Mac OS. Both have the same problem: how to install yarn properly when you use nvm?

nvm, as you know, is an isolated nodejs manager. But when you do brew install yarn or sudo apt-get install yarn, then a system-wide nodejs version is installed (as a dependency)

This nodejs dependency is breaking a lot on my machines. This isn't working well. Ideally it would be good if we still can install and upgrade yarn through npm; or at least make brew + apt-get smarter, not installing the nodejs dependency when nvm already exist.

Looking at older issues, I see this has been discussed but there are too many comments to process. Can we agree to an official solution to the above and document this on the installation page?

@Daniel15
Copy link
Member

Daniel15 commented Apr 28, 2017

On Debian-based distros (including Ubuntu), you install Yarn this way to avoid installing a Node.js package:

apt-get install --no-install-recommends yarn

Homebrew has a similar flag, but I can't remember it off the top of my head.

The install script will also work:

curl -o- -L https://yarnpkg.com/install.sh | bash

@rally25rs
Copy link
Contributor

@bestander triage; label: [documentation] (which doesn't seem to be an existing label... perhaps worth making?)

@bestander
Copy link
Member

now we have :)

@binarykitchen
Copy link
Contributor Author

thanks for that - yeah, please document.

and curl -o- -L https://yarnpkg.com/install.sh | bash is not an option for me because it does not get automatically updates like apt-get and brew do.

@bestander
Copy link
Member

This is a community project, we hope that people who need this would step in and help each other, e.g. send a PR for documentation.

@binarykitchen
Copy link
Contributor Author

alright, i ll do a PR next week. can you confirm the curl command installs only but doesn't update?

@bestander
Copy link
Member

That script should update

@ntwb
Copy link

ntwb commented May 28, 2017

Quoting @Daniel15 #3255 (comment):
"...Homebrew has a similar flag, but I can't remember it off the top of my head."

I don't see that option in the formula: https://github.com/Homebrew/homebrew-core/blob/master/Formula/yarn.rb, I've opened Homebrew/homebrew-core#14026 for this to be added to the Yarn Homebrew package.

@Daniel15
Copy link
Member

I think there's an --ignore-dependencies flag

Sent from my phone.

@ntwb
Copy link

ntwb commented May 29, 2017

I created yarnpkg/website#516 per the above

@app
Copy link

app commented Jul 3, 2017

@Daniel15

apt-get install --no-install-recommends yarn
Thanks. It works!
And what about next time I run sudo apt upgrade ? Will new version of yarn install nodejs?

@andrewhavens
Copy link

Just an update for anyone who comes across this issue via Google search...Yarn documentation now says that Yarn can be installed on a Mac, via Homebrew, without node, like this:

brew install yarn --without-node

@idkjs
Copy link

idkjs commented Oct 4, 2017

@andrewhavens your note timestamp is right on time. TY

@chris-orchard
Copy link

chris-orchard commented Apr 13, 2018

@app

@Daniel15

apt-get install --no-install-recommends yarn
Thanks. It works!
And what about next time I run sudo apt upgrade ? Will new version of yarn install nodejs?

Was there an answer to this? If I apt-get install --no-install-recommends yarn will nodejs be installed when I upgrade or not?

@Daniel15
Copy link
Member

Sorry I didn't answer that! It shouldn't - AFAIK Debian only looks at "recommended" packages on initial installation, not on upgrades.

@stevecj
Copy link

stevecj commented Apr 26, 2018

What about installing on CentOS/Fedora using nvm?
Yes, this is something that I actually need to do.

@stevecj
Copy link

stevecj commented Apr 26, 2018

yum says the following…

===========================================================================================================================================================================
 Package                                Arch                                   Version                                          Repository                            Size
===========================================================================================================================================================================
Installing:
 yarn                                   noarch                                 1.6.0-1                                          yarn                                 916 k
Installing for dependencies:
 libuv                                  x86_64                                 1:0.10.34-1.el6                                  epel                                  57 k
 nodejs                                 x86_64                                 0.10.48-3.el6                                    epel                                 2.1 M

Transaction Summary
===========================================================================================================================================================================
Install       3 Package(s)

Total download size: 3.0 M
Installed size: 11 M
Is this ok [y/N]:

I presume I want to install yarn and libuv but not nodejs. Correct?

--- edit ---

Actually, it looks like libuv is a dependency of node so it should already be managed by nvm — so I just want yarn itself and none of the dependencies?

@stevecj
Copy link

stevecj commented Apr 26, 2018

Maybe I'm missing the obvious. There is presumably no harm in having the node package installed when I am using nvm. Right? That means I don't actually have to skip installing the dependencies (which can't be done via yum without first modifying the package).

@devxpy
Copy link

devxpy commented May 19, 2018

Anyone know how to do this on Solus?

@devxpy
Copy link

devxpy commented May 19, 2018

sudo eopkg install yarn --ignore-dependency

@jcollum
Copy link

jcollum commented Aug 14, 2018

@binarykitchen can you add @andrewhavens comment to your initial comment as an edit? it would be very helpful to have that at the top of the page for people who come here from google.

@ivanovv
Copy link

ivanovv commented Jan 24, 2019

brew install yarn --without-node

still wants to install node:

$> brew install yarn --without-node
==> Installing dependencies for yarn: python, sphinx-doc, python@2, icu4c and node

I guess it is because of this commit Homebrew/homebrew-core@a34c721 but I'm not 100% sure as I have little knowledge of Homebrew.

wkoffel referenced this issue in Homebrew/homebrew-core Jan 28, 2019
@wadkar
Copy link

wadkar commented Feb 13, 2020

Following @andrewhavens comment in the thread, another update for anyone who comes across this issue via Google search.

Yarn documentation currently says to install using brew install yarn and mentions that it'll pull in the node dependency (and transitively pull python2, icu4c).

Point being, homebrew devs are essentially saying that you must install node from homebrew because homebrew doesn't support installation options anymore (warning long thread, lots of heated discussion). And because yarn cannot work without node, obviously, they will install a system wide node for you.

If you still don't want to install node from homebrew simply do brew install yarn --ignore-dependencies. Make sure your $PATH is sorted properly as mentioned in the docs.

@alexraileanu
Copy link

if anyone else comes across this issue from google and has the following setup like me: node installed from nvm, path correctly updated to include nvm's binary path but brew will still refuse to use that node version, you can try the following:

you can use brew edit yarn to temporarily comment out the depends_on "node" line and yarn will be installed without the node dependency. worked great for me. again, make sure that you have a node version present in your $PATH

@wadkar
Copy link

wadkar commented Apr 6, 2020

@alexraileanu brew install --ignore-dependencies yarn does exactly that (yours is a precise way of excluding the node as dependency), but you'll have brew complaining next time yarn formula gets updated.

@alexraileanu
Copy link

alexraileanu commented Apr 7, 2020

@wadkar yeah tho in my case, for whatever reason, brew would not find the node binary in my path so when i ran with --ignore-dependencies it would try to execute node from /usr/local which i didn't have. which is why i had to comment that requirement out.

@ramigs
Copy link

ramigs commented Aug 22, 2020

thanks @alexraileanu
the only solution that worked for me in macOS Catalina.

@AlecRust
Copy link

It now seems the recommended way to install yarn is via npm.

So if you're using nvm, Homebrew should not be used for Node (to avoid an extra Homebrew Node being installed) or yarn (to avoid yarn being installed outside of nvm).

nvm will use $NVM_DIR/default-packages file if it exists to install global Node packages, via npm. So this is how I now install yarn (dotfiles example).

Glad to be corrected, but this seems to be the most up-to-date way of installing yarn when using nvm.

Interestingly, this does seem to mean that sometimes which yarn returns a function, and sometimes a path to the yarn binary within nvm.

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.