I punched this into Terminal
$ brew install yarn
now npm no longer works
$ npm
-bash: /usr/local/bin/npm: No such file or directory
tried to reinstall npm
$ brew install npm
Warning: node 10.0.0 is already installed, it's just not linked
You can use `brew link node` to link this version.
followed instructions to $ brew link node
$ brew link node
Linking /usr/local/Cellar/node/10.0.0...
Error: Could not symlink include/node/android-ifaddrs.h
Target /usr/local/include/node/android-ifaddrs.h
already exists. You may want to remove it:
rm '/usr/local/include/node/android-ifaddrs.h'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
attempted to $ brew link --overwrite node
$ brew link --overwrite node
Linking /usr/local/Cellar/node/10.0.0...
Error: Could not symlink include/node/android-ifaddrs.h
/usr/local/include/node is not writable.
attempted to $ sudo brew link --overwrite node
$ sudo brew link --overwrite node
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
I am at a loss.
As noted in the install docs
If you use nvm or similar, you should exclude installing Node.js so that nvm鈥檚 version of Node.js is used.
brew install yarn --without-node
The yarn package has a dependency on node, so brew will also install node, which in turn installs npm.
"... is not writable" sounds like permissions on that link might be messed up. Maybe try removing the link first?
sudo rm /usr/local/include/node
brew link --overwrite node
Had the same issue, had to reinstall and relink. But as @rally25rs stated, the install docs note about --without-node solves this as well on reinstall.
It's striking that --without-node is _not_ the default behaviour. The negative connotation of the argument name should have been the first red flag.
@rally25rs
brew install yarn should default to brew install yarn --without-node
brew install yarn --with-node should be the optional flag
the current system assumes that everyone installing yarn does not have npm installed on their machine which, to the best of my knowledge, is statistically unlikely.
Personally, I have avoided using yarn since this issue. Sour taste. npm works fine and doesn't break my dev environment.
PS; eg33 swap it @rally25rs ;)
Going against my better judgement I was forced to install yet-another-tool and ran brew install yarn --without-node. Yes, with the flag. Now my npm is hosed and instead of doing real work I'm fiddling with tools.
Fixed: brew uninstall yarn --force then reinstall npm.
I followed these steps from @rally25rs:
As noted in the install docs
If you use nvm or similar, you should exclude installing Node.js so that nvm鈥檚 version of Node.js is used.
brew install yarn --without-nodeThe yarn package has a dependency on node, so brew will also install node, which in turn installs npm.
"... is not writable" sounds like permissions on that link might be messed up. Maybe try removing the link first?
sudo rm /usr/local/include/node brew link --overwrite node
but I got
Linking /usr/local/Cellar/node/12.6.0...
Error: Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.
@nschmeller
It's working my side after run this code
sudo chown -R $(whoami) $(brew --prefix)/* (Mac OS) Stackoverflow
brew link --overwrite node
brew reinstall node
brew install yarn --ignore-dependencies Github
The last time I installed yarn it took me over a day to get my system working again
I agree wholeheartedly: an option with negative connotation is a red flag
but I need yarn to do an Electron build - so I'm stuck
and this is broken: brew install yarn --without-node
(says Error: invalid option: --without-node)
so it's going to be: brew install yarn --ignore-dependencies
(clearly described as: An unsupported Homebrew development flag to skip installing any dependencies of any kind.)
this is so wrong (looks away while hitting return...)
whew !! It didn't not work !! (is a double-negative connotation a better thing?)
ok! relying on an unsupported flag to install a tool that has to be installed in solitary confinement to avoid destroying my development environment...
clench 'em if you've got 'em
Most helpful comment
@rally25rs
brew install yarnshould default tobrew install yarn --without-nodebrew install yarn --with-nodeshould be the optional flagthe current system assumes that everyone installing yarn does not have npm installed on their machine which, to the best of my knowledge, is statistically unlikely.
Personally, I have avoided using
yarnsince this issue. Sour taste. npm works fine and doesn't break my dev environment.PS; eg33 swap it @rally25rs ;)