Use node from homebrew
Asked Answered
D

3

10

Running node -v in the terminal returns 0.12.2, while running brew info node to check homebrew's version of node, it returns 6.7.0

How can I work using homebrew's node? (6.7.0 instead of 0.12.2)

I've tried reinstalling everything, but it didn't work.

Dakar answered 8/10, 2016 at 0:5 Comment(0)
P
7

Two options...

Either specify the full path to where hombrew installed node each and every time you use it:

/usr/local/bin/node -v

Or, change your PATH in your login profile to put /usr/local/bin ahead of everything else:

export PATH=/usr/local/bin:$PATH 
Peyter answered 8/10, 2016 at 0:28 Comment(9)
I've tried that, but running node -v still returns 0.12.2. If its pointing to the homebrew folder, shouldn't it return the same version I see when I run brew info node?Dakar
If you exported the PATH in your login profile, it will only execute next time you log in. To set it in your current session (without logging in afresh), just type the command in Terminal export PATH=/usr/local/bin:$PATH. Then try node -v again.Peyter
Nope. Tried it now, but its not changing the return of node -v :/Dakar
Try /usr/local/bin/node -vPeyter
It returns 0.12.2 as wellDakar
Try brew rm node --force; brew install node and check any warnings about not linkingPeyter
Thanks. I found an error with the brew link. Forcing the overwrite of the link solved the problemDakar
I am going to bed now! If that didn't work, try brew doctor and let it tell you what is wrong with your setup. And if that doesn't work, try running type node to see if it is aliased or something mad, other than /usr/local/bin/node. Finally, pretend your Mac is Windows and try rebooting it.Peyter
Excellent! I'm glad it helped :-)Peyter
P
4

Don't use homebrew, use nvm. https://github.com/creationix/nvm

Not only is it easier to install and use, it also allows you to have multiple versions of node/npm installed and switch between them effortlessly (e.g. nvm install v6.7.0 and nvm use v6.7.0)

Photina answered 8/10, 2016 at 7:3 Comment(0)
N
0

If you use the homebrew you can use the below path on ~/.bash_profile

export PATH=/opt/homebrew/bin/:$PATH   
Nameless answered 15/7 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.