Node and NPM Setup and Installation
Overview
Node and the node package manager (NPM) are used to install and manage the tools and libraries that will be used in this course and are required.
Node and NPM
Node is a JavaScript runtime that has gained a lot of popularity in the last few years. There are many helpful tools and utilities that can be run using it. NPM is the Node Package Manager. It gets installed automatically with Node and is used to add and remove utilities.
For more detailed instructions visit: http://blog.teamtreehouse.com/install-node-js-npm-windows
Check Prior Installation
Before installing Node.js, ensure you do not already have Node.js installed.
- Open up a terminal (Mac) or CMD prompt/PowerShell (Windows) window.
- Type
node -v
ornode --version
. - If a version number is provided (e.g.,
v
), you already have Node.
Installation
Windows Users
- Download the recommended LTS version Windows installer from the Node.js® web site.
- Run the installer (the .msi file you downloaded in the previous step.)
- Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).
- Restart your computer. You won't be able to run Node.js® until you restart your computer.
-
To verify that it worked type the following in the command prompt:
node -v
. If you get the version number back you are good to go.
macOS Users
For the mac we are going to install the Node Version Manager (nvm) tool first, and then we will use that to install Node. There are a couple of advantages to doing it this way...the biggest of which is that it makes it really easy to switch versions of Node when needed (happens more than you might think as a developer) Before we can install that however, we need the Apple developer tools. You can get those in one of two ways:
- If you think you will ever want to build native MacOS or IOS apps download and install XCode. Apple’s XCode development software is used to build Mac and iOS apps, but it also includes the tools you need to compile software for use on your Mac. XCode is free and you can find it in the XCode on iTunes. After you install it, open it at least once to accept the Terms. The next step won't work unless you do.
- *Recommended for most! If you don't want to download and install the full XCode (It's quite large), you can install just the developer tools by following these instructions.
Installing Node and NPM with nvm is pretty straightforward.
-
To install nvm, open the Terminal app and
type:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
-
Once nvm is done installing you can grab the latest copy of the Long
Term Support (LTS) version by typing the following:
nvm install --lts
-
To verify that it worked type the following in the terminal:
node -v
. If you get the version number back you are good to go.
Since macOS 10.15, the default shell is zsh and nvm will look for .zshrc to update, none is installed by default. If you get an error installing above, create this file by typing the following in your terminal:
touch ~/.zshrc