Hopefully you're excited about Node by now. But before we can go any further, we need to install it on our system.
There are a few ways to install Node and npm. Our recommendation is to use one-click installer. Sometimes you might work on projects which require different versions of Node and/or npm. We'll cover how to switch between them too. In this case use
For the very advanced developers, there are a few recipes like installing from the source code or taking ownership. If you are total beginner, stick with one-click installer or n/nave/nvm.
If you already have Homebrew (
brew) installed, straightforwardly run:
brew install node
This command will install the latest brewed versions of both Node.js and npm.
Installing Node.js with the package manager of your choice should look essentially like the above installation with Homebrew. Note that on Debian-based systems, you'll need to
sudo apt-get install node.js, because a
node package other than Node.js already exists in apt.
To test your installations, run these commands in your Terminal app (command line
cmd.exe in Windows):
node -v npm -v
As of this writing (8 July 2016), you should have Node.js v6.3.0 and npm v3.10.x ("x" will be a number but it seems like it'll change imminently). Alternatively, run the tests for this lessons with
As you work with different Node.js projects, you'll find that you need to change versions from time to time. There are many version managers available for Node.js, such as nvm, or even virtual environment managers like nave.
We prefer to use n. To get started, simply run
npm install -g n
n globally on your system.
n installed, switching to a new version is as simple as running
Where "6.2.0" could be any version that you need. Use
n --help to explore your options and learn how to use it!
View node-install-lab on Learn.co and start learning to code for free.