How to install node.js on macOS with nodebrew.
Tags: node
Published: 2017-12-28 12:59:37

---
title: How to install node.js on macOS with nodebrew.
published: true
description: for node.js beginner
tags: node
---

# Install Homebrew
See below:
[Homebrew(official)](https://brew.sh/)

# Install nodebrew
After you installed Homebrew, you should execute below
```
brew install nodebrew
```

If you want to check whether you could get it or not, please type this command.
```
nodebrew -v
```
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
```

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
```

# Install node.js
Before you install node.js, check the latest version of node.js on official website.
[node.js official website](https://nodejs.org/en/)
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
```

Can you find out the version you want? O.K. Let's install it.
```
nodebrew install-binary <THE-VERSION-YOU-WANT>
```
Please replace the <THE-VERSION-YOU-WANT> 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
```
Make the folder which is needed with this command.
```
mkdir -p ~/.nodebrew/src
```
and retry `nodebrew install-binary <THE-VERSION-YOU-WANT>`

# Launch node.js
Before launching node.js, check the nodebrew.
```
nodebrew ls
```
You can get like below:
```
v8.9.3

current: none
```
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>
```

After that, please execute this
```
node -v
```
If you could set node.js appropriately, you can get the return about the node.js version like below.
```
v8.9.3
```

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