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

Best way to install Node JS on OS X #35

Closed
surfeatsleep opened this issue Nov 23, 2015 · 26 comments
Closed

Best way to install Node JS on OS X #35

surfeatsleep opened this issue Nov 23, 2015 · 26 comments

Comments

@surfeatsleep
Copy link

moved from nodejs/node#3969 (comment)

While the installer available at https://nodejs.org/en/ seems logical to pick, there are numerous blog posts, tutorials, stackoverflow questions, etc. that point to and even highly recommend alternatives.

All of these different recommendations make installing Node JS on OS X a bit confusing.

My question is:
regarding simplicity of installing, updating and uninstalling as well as being safe to use (even for beginners), which of the following is the best way to install Node and why:

  • use the installer from https://nodejs.org/en/
  • homebrew
  • nvm
  • using homebrew to install nvm and than using nvm to install Node (this seems to be the top recommended alternative to the installer)
  • any other way

Some of the reasons why to choose each of the methods:

Use installer
Easiest to install.
Although it seems to be suggested as the best way, since it is on the Node JS homepage, it can be difficult to uninstall, requires adding the path to the node executable to your system $PATH and also affects admin-only system folders.

Homebrew
Easy to uninstall and update, does not require sudo for installing node packages globally.
However it can be a bit buggy at times, needing for workarounds to make it work correctly.

nvm
Easy to uninstall and update, allows multiple versions.
This seems to be quite a good alternative, yet might seem a bit too much if you only need the latest version.

Homebrew to install nvm, nvm to install node
Benefits of easier updating nvm (along with other software used) while getting the flexibility of nvm to work with node, also nvm supposedly installs Node JS in a better way than homebrew directly.
The negative is you install two things simply to install and manage the third.

Any other way
more customisation?
Not sure about the benefits or issues with other alternatives

@Trott
Copy link
Member

Trott commented Nov 23, 2015

This is a matter of opinion and I suspect opinions vary pretty widely on this. I use nvm (without homebrew) and it works very well for me. I'm not sure it would be good for a server, but for a development environment where I want node installed specifically for me and not for the system and I want to be able to change to different versions easily, it's been great.

@evanlucas
Copy link

I personally install node from the pkg downloaded from nodejs.org and then npm install -g n and use n to manage my node versions

@docjojo
Copy link

docjojo commented Dec 1, 2015

How about the uninstall process?
What is the best way to uninstall on MacOS?

@Trott
Copy link
Member

Trott commented Dec 1, 2015

Best way to uninstall is going to depend on how it was initially installed.

@docjojo
Copy link

docjojo commented Dec 1, 2015

I used the node-v4.2.2.pkg MacOSX Installer... but there is not uninstall tool.

@johan718
Copy link

johan718 commented Dec 9, 2015

I also use a mac, OSX 10.10, I have node v0.10.35. I would like to upgrade and it seems that the easiest way would be to just install the latest stable version over my old installation. Is this correct and does it work?

I have no problem using macports to manage versions of node--or any other stable node managers--but I would like the latest official version as a global installation. Does this make sense?

@johan718
Copy link

johan718 commented Dec 9, 2015

I also installed v0.10.35 globally with a binary from nodejs.org. I'm also curious to know how I would uninstall if I run into trouble installing a new version over my old version (using official binary).

@evanlucas
Copy link

The files are installed to /usr/local. They would have to be removed manually for now. There is a pull request open to add and uninstaller for OS X though. As for installing a newer version, you should be able to just install the .pkg from nodejs.org. A few people have mentioned issues regarding npm with node v5. If you run into any trouble with that, simply rm -rf /usr/local/lib/node_modules/npm and then reinstall using the new .pkg again.

@johan718
Copy link

johan718 commented Dec 9, 2015

Thanks @evanlucas. Good to know. I'll try it. I'm trying to get busy with some code here!!!

@docjojo
Copy link

docjojo commented Dec 9, 2015

Thank you!

@johan718
Copy link

@evanlucas can you give me some examples of issues where I should try and fix by removing the node_modules/npm folder?

The reason I ask is because I just tried installing learnyounode and it gave me an EACCES error. I know this may not be the correct place to ask, but is this normal? I plan on just using sudo in this case. If you think I should try erasing node_modules/npm--as you suggested above--let me know.

@evanlucas
Copy link

@johan718 no I wouldn't do it unless you are unable to run npm at all. There have been some cases with v5 on OS X where the npm installation got botched. An EACCES error means that you probably need to run npm with sudo. Btw, this is exactly the place to ask :]

For posterity, the issue related to the botched install is nodejs/node#3606

@johan718
Copy link

@evanlucas thanks a lot! Got it. My node_modules folder is owned by "nobody". Does this sound normal to you?

@evanlucas
Copy link

I believe that is what it defaults to (someone please correct me if I'm wrong). Some developers that use OS X use the homebrew package manager and that changes the permissions of /usr/local. If you use homebrew, the directory will generally belong to your user instead of nobody.

@johan718
Copy link

Yeah. Ok, sounds good. Thanks a lot for all your help @evanlucas! I'll comment if I run into any other issues.

@robertandrews
Copy link

How can I uninstall this please?
I installed Node.js/NPM 4.2.4 LTS from https://nodejs.org/en/ to Mac OS X 10.10.4 with default options, but, not really being a developer, I am out of my depth and want it gone entirely. I'd appreciate your help.
Thanks.

@Knighton910
Copy link
Contributor

Hey @robertandrews: go to /usr/local/lib and delete any node and node_modules
go to /usr/local/include and delete any node and node_modules directory
if you installed with brew install node, then run brew uninstall node in your terminal

👍 go here for more: http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x of-course don't worry about the reinstallation bit 💯

@robertandrews
Copy link

Thanks, @kelthenoble.

/usr/local/lib contains two folders:

  • dtrace
  • node_modules

/usr/local/bin contains three files:

  • grunt
  • node
  • npm

But grunt and npm seem to be aliases/symlinks.
I don't remember putting grunt there.

@Knighton910
Copy link
Contributor

maybe at some point you ran

npm i -g grunt

but moving on delete those, if you don't wish to keep them.
Hit me up if you need more help.

@dreamyguy
Copy link

For those in the future finding this through Google...

I've revisited the StackOverflow question mentioned by @lordKnighton a few times, but one answer pointed me to a very good direction: https://github.com/brock/node-reinstall

I have used that script myself several times and helped colleagues reset their node environments with it, and it never let me down.

@Knighton910
Copy link
Contributor

Thanks for sharing @dreamyguy :)
😄

@cyfyifanchen
Copy link

I ran into the same problem last night. When I tried to install it again, there are too many different answers. My co-worker told me that nvm is the way to go. I guess there is another con with brew install node regarding the issue here https://gist.github.com/DanHerbert/9520689.

@Knighton910
Copy link
Contributor

Let us know if your good, on your installation @yifanchen, closing for now.

@cyfyifanchen
Copy link

@lordKnighton good to know, thanks.

@RileyManda
Copy link

RileyManda commented Apr 19, 2018

Best way to uninstall node on mac is to run the following command on your terminal:
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man//node.}

@ORESoftware
Copy link

use NVM, does not require root privileges
https://github.com/creationix/nvm

or use homebrew...but NVM is probably best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests