WDD 430: Web Full-Stack Development

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

For more detailed instructions visit: http://blog.teamtreehouse.com/install-node-js-npm-windows)

Check Prior Installation

Before following the instructions below make sure that you do not already have Node installed.

  1. Open up a terminal (Mac) or CMD prompt/PowerShell (Windows) window.
  2. Type node -v or node --version.
  3. If it gives you a version and NOT an error you already have Node.

Installation

Windows Users
  1. Download the Windows installer from the Node.js® web site. You will want to grab the Recommended version (LTS) instead of the latest version!
  2. Run the installer (the .msi file you downloaded in the previous step.)
  3. Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).
  4. Restart your computer. You won't be able to run Node.js® until you restart your computer.
  5. 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:

  1. 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.
  2. *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. The commands below follow the official nvm installation instructions.

  1. If you use the default macOS shell (zsh), create its configuration file first. This lets the nvm installer add the command that loads nvm whenever you open a new terminal.
    touch ~/.zshrc
  2. To install nvm, open the Terminal app and type:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bash

    Check the official nvm instructions above for the current release before running the command, since this installer URL is intentionally version-pinned.

  3. Close and reopen Terminal, then verify that nvm loaded correctly. The command should print nvm.
    command -v nvm
  4. 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
  5. To verify that it worked, type the following in the terminal. If both commands return version numbers, you are good to go.
    node -v
    npm -v

If command -v nvm prints nothing, reopen Terminal once more. If it still does not print nvm, return to the official nvm instructions linked above and follow their profile-file troubleshooting steps.

⬅️Return to Setup