Setup: Node and Node Package Manager (npm)
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.
Node is a popular, open-source, cross-platform JavaScript runtime environment. 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.
Instructions
Check Prior Installation
Before following the instructions below make sure that you do not already have Node installed.
- Open up a terminal (Mac) or CMD prompt/PowerShell (Windows) window.
- Type
node -v
ornode --version
. - If it gives you a version and NOT an error you already have Node.
Installation
Windows Users
- Download the Windows installer from the Node.js® web site. You will want to grab the Recommended version (LTS) instead of the latest version!
- 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, install the Node Version Manager (nvm) tool first, and then you will use that to install Node. There are advantages to doing in this order, the biggest is that switching versions of Node is easy. Apple Developer Tools is needed in order to install and you can get it in a couple of 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 Apple App Store. 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