Node Js Brew



  1. Nodejs Breaking Changes
  2. How To Install Node Js
  3. Node Js Browser Automation
  4. Install Node Js Brew Mac

Node version manager is a script to manage multiple active node.js versions. And I usually install most applications using homebrew.
NOTE:install NVM with Homebrew is not officially supported.

As of this PR to homebrew/versions and this PR to homebrew, the answers involving brew tap homebrew/versions or.-lts packages no longer work. The correct answer is now: brew install node@version Where version is 0.10, 0.12, 4, etc. For example, to install Node.js v6 (as of this writing, the most recent LTS version): brew install node@6.

  • In this article, We are going to perform Download Node.js package for Mac OS, Install Node.js on mac OS using Macintosh Installer, Install Node.js on macOS using Home brew, Installing Node.js and NPM using NVM on Mac OS, Uninstall/Remove Node.js and NPM from MacOS.
  • The latest version of NodeJs right now is 0.4.1. The command brew install node right now, installs 0.2.6 - which is not ideal. I would like 0.4.1. I've looked at this list of commands for brew and tried brew install -HEAD node.

So these are the steps to install NVM with Homebrew:

  1. Install NVM with Homebrew
    Install NVM is very easy just with this command:
  1. First setup
    The first thing we need to do is create a folder for the current user .nvm where the files will reside.
  1. Install a node version
    There are different node versions that you can install; if you want to install the last version is very simple just using the command:

But I work with the long-term support version and the command to install the last LTS version is the command below:

  1. Start using the node version installed with NVM
    After you installed the node version that you are looking it will be active after this command:

The previous command is also useful if you want to change from different Node.js versions.

To check if everything is working as expected the command bellow print the node version:

Finally, we want to execute NVM in every shell session, so let's create two user environment variables NVM_DIR and NVM_HOMEBREW.
Generally, environment variables are going in the file ~/.bash_profile if you are using BASH or in the ~/.zshenv file if you are using ZSH, but it will work also if you want to put the code below in the file ~/.bashrc for BASH or ~/.zshrc for ZSH.

You can use '$(brew --prefix nvm)/nvm.sh' instead of '/usr/local/opt/nvm/nvm.sh' but it will be slower.

The NODE_PATH variable can also be useful for some applications, for example, VScode, this is the code you need to put after the previous variables.

Question or issue on macOS:

I am trying to use homebrew as much as possible. What’s the suggested way to install the following on OS X?

and hopefully supports development for:

How to solve this problem?

Solution no. 1:

  1. Using homebrew install nvm:

    Add the last command to the .profile, .bashrc or .zshrc file to not run it again on every terminal start. So for example to add it to the .profile run:

    If you have trouble with installing nvm using brew you can install it manually (see here)

  2. Using nvm install node or iojs (you can install any version you want):

  3. npm is shipping with node (or iojs), so it will be available after installing node (or iojs). You may want to upgrade it to the latest version:

    UPD Previous version was npm update -g npm. Thanks to @Metallica for pointing to the correct way (look at the comment bellow).

  4. Using npm install ionic:

  5. What about ngCordova: you can install it using npm or bower. I don’t know what variant is more fit for you, it depends on the package manager you want to use for the client side. So I’ll describe them both:

    1. Using npm: Go to your project folder and install ng-cordova in it:

    2. Using bower: Install bower:

      And then go to your project folder and install ngCordova in it:

PS

  1. Some commands may require superuser privilege
  2. Short variant of npm install some_module is npm i some_module

Solution no. 2:

Brew
2019 update: Use NVM to install node, not Homebrew

In most of the answers , recommended way to install nvm is to use Homebrew

Do not do that

At Github Page for nvm it is clearly called out:


Homebrew installation is not supported. If you have issues with
homebrew-installed nvm, please brew uninstall it, and install it using
the instructions below, before filing an issue.

Use the following method instead

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

And then use nvm to install node. For example to install latest LTS version do:

Clean and hassle free. It would mark this as your default node version as well so you should be all set

Solution no. 3:

I’m using n (Node version management)

You can install it in two ways

or

You can switch between different version of node and io. Here’s an example from my current env when I call n without params:

Solution no. 4:

I’m super late to this but I didn’t like the other answers

Installing Homebrew

For brew run

Installing node & npm

You SHOULD NOT use brew to install node and npm.

I’ve seen a few places suggested that you should use Homebrew to install Node (like alexpods answer and in this Team Treehouse blog Post) but installing this way you’re more prone to run into issues as npm and brew are both package managers and you should have a package manager manage another package manager this leads to problems, like this bug offical npm issues Error: Refusing to delete: /usr/local/bin/npm or this Can’t uninstall npm module on OSX

You can read more on the topic in DanHerbert’s post Fixing npm On Mac OS X for Homebrew Users, where he goes on to say


Also, using the Homebrew installation of npm will require you to use sudo when installing global packages. Since one of the core ideas behind Homebrew is that apps can be installed without giving them root access, this is a bad idea.

For Everything else

I’d use npm; but you really should just follow the install instruction for each modules following the directions on there website as they will be more aware of any issue or bug they have than anyone else

Solution no. 5:

If you have previously installed node using brew, then you will have a bunch of extra files that you should clean up before installing node “the right way”. Plus, I had to add a few settings to my startup script to make things work smoothly.

I wrote a script to make this easy.

I wrote a short article here that details why this is “the right way”.

If you need to install iojs, do so using nvm like this:

To install brew, just see its home page.

See alexpods answer for the rest.

Solution no. 6:

You should install node.js with nvm, because that way you do not have to provide superuser privileges when installing global packages (you can simply execute “npm install -g packagename” without prepending ‘sudo’).

Update node js brew

Brew is fantastic for other things, however. I tend to be biased towards Bower whenever I have the option to install something with Bower.

Solution no. 7:

I agree with noa — if you need to have multiple versions of node, io.js then brew is not the appropriate solution.

You can help beta-test io.js support in nvm: https://github.com/creationix/nvm/pull/616

If you just want io.js and are not switching versions, then you can install the binary distribution of io.js from https://iojs.org/dist/v1.0.2/iojs-v1.0.2-darwin-x64.tar.gz ; that includes npm and you will not need nvm if you are not switching versions.

Remember to update npm after installing: sudo npm install -g [email protected]

Solution no. 8:

Here’s what I do:

No Homebrew for this one.

nvm soon will support io.js, but not at time of posting: https://github.com/creationix/nvm/issues/590

Then install everything else, per-project, with a package.json and npm install.

Nodejs Breaking Changes

Solution no. 9:

How To Install Node Js

For install with zsh and Homebrew:

Then Add the following to ~/.zshrc or your desired shell
configuration file:

Node Js Browser Automation

Then install a node version and use it.

Install Node Js Brew Mac

Hope this helps!





Comments are closed.