How to install node.js on macOS with nodebrew.

toyotarone

Koji Toyota

Posted on December 28, 2017

How to install node.js on macOS with nodebrew.

Install Homebrew

See below:
Homebrew(official)

Install nodebrew

After you installed Homebrew, you should execute below

brew install nodebrew
Enter fullscreen mode Exit fullscreen mode

If you want to check whether you could get it or not, please type this command.

nodebrew -v
Enter fullscreen mode Exit fullscreen mode

and you can see the version of your nodebrew.

nodebrew 0.9.8

Usage:
    nodebrew help                         Show this message
    nodebrew install <version>            Download and install <version> (compile from source)
    nodebrew install-binary <version>     Download and install <version> (binary file)
    nodebrew uninstall <version>          Uninstall <version>
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for `list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias <key> <value>          Set alias
    nodebrew unalias <key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
    nodebrew exec <version> -- <command>  Execute <command> using specified <version>

Example:
    # install from binary
    nodebrew install-binary v0.10.22

    # use a specific version number
    nodebrew use v0.10.22

    # io.js
    nodebrew install-binary io@v1.0.0
    nodebrew use io@v1.0.0
Enter fullscreen mode Exit fullscreen mode

After you installed nodebrew, I recommend you to add the PATH of nodebrew to your .bash_profile.

echo 'export PATH=$PATH:$HOME/.nodebrew/current/bin' >> ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

Install node.js

Before you install node.js, check the latest version of node.js on official website.
node.js official website
You might find out 2 or more versions of node.js.
I recommend you to install LTS(Long Term Support) version.

If you decided the version, type below and you can see all versions you can install.

nodebrew ls-remote
Enter fullscreen mode Exit fullscreen mode

Can you find out the version you want? O.K. Let's install it.

nodebrew install-binary <THE-VERSION-YOU-WANT>
Enter fullscreen mode Exit fullscreen mode

Please replace the to the version you want to install.

If you get error like below,

Warning: Failed to create the file 
Warning: /Users/<YOUR-USER-NAME>/.nodebrew/src/v8.9.3/node-v8.9.3-darwin-x64.tar.gz: No 
Warning: such file or directory
Enter fullscreen mode Exit fullscreen mode

Make the folder which is needed with this command.

mkdir -p ~/.nodebrew/src
Enter fullscreen mode Exit fullscreen mode

and retry nodebrew install-binary <THE-VERSION-YOU-WANT>

Launch node.js

Before launching node.js, check the nodebrew.

nodebrew ls
Enter fullscreen mode Exit fullscreen mode

You can get like below:

v8.9.3

current: none
Enter fullscreen mode Exit fullscreen mode

This is the list of node.js versions you have and current node.js version.
The line current: none means your system haven't set the node.js.
So, type this

nodebrew use <THE-VERSION-YOU-WANT>
Enter fullscreen mode Exit fullscreen mode

After that, please execute this

node -v
Enter fullscreen mode Exit fullscreen mode

If you could set node.js appropriately, you can get the return about the node.js version like below.

v8.9.3
Enter fullscreen mode Exit fullscreen mode

That's all! Now you can build amazing project with node.js!

💖 💪 🙅 🚩
toyotarone
Koji Toyota

Posted on December 28, 2017

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related