Setting Up Node Locally
What is Node?
Node.js is a JavaScript runtime, which is an environment that executes JavaScript code. Web browsers also contain a JavaScript runtime environment. A “runtime” converts code written in a high-level, human-readable programming language (such as JavaScript) and compiles it down to code that the computer can execute. Node was created with the goal of building web servers and web applications in JavaScript, but it’s a powerful and flexible environment that can be used for building a wide range of applications.
Installing Node
When you’re ready, running Node on your own computer is an exciting step towards becoming a developer. Experimenting with the Node REPL in your own terminal and executing your first local JavaScript program will set you on your way to building all sorts of exciting projects.
Before you install Node, you’ll need to make sure you have your command line set up. Mac and Linux machines come pre-built with a Terminal application that is suitable for this process. If you are using a Windows machine, you will need to follow the instructions in the article to download Git Bash.
First, navigate to the Node website. From here, you can learn more about Node and its capabilities, browse the official documentation, and keep up with the latest on Node. To download Node.js, select “Get Node.js”, or head directly to the Node downloads page.
On the downloads page, there are two options for downloading Node.js and related applications:
- Download Node.js with a version manager and a package manager via the terminal.
- Download Node.js (and a package manager) via a desktop installer.
Both of these options will dynamically respond to your operating system and architecture. We will use the first option, which downloads Node.js with a version manager and a package manager.
A version manager allows us to download and manage multiple versions of Node on the same machine, which can be quite difficult otherwise. This is particularly helpful if you plan to work on multiple projects over time, where different projects require different versions of Node to be run. nvm, which stands for Node Version Manager, is the most popular version manager for Node.
Both options will also download npm by default, Node Package Manager. To learn more about npm, check out our article on Getting Started with Node Package Manager.
Note: If you are using Windows, make sure you read the article on setting up the command line and download Git Bash — you’ll need to use Git Bash to run the download commands and execute Node programs. Additionally, in the next list, you’ll need to choose “macOS” or “Linux” as the operating system, “nvm” as the version manager, and “npm” as the package manager. nvm is not compatible with Windows directly, but since Git Bash performs similarly to Mac and Linux terminals, it allows us to use nvm.
Look over the four options available:
- The Node version — by default, it will download the most recent version that is in LTS (Long-Term Support). We recommend accepting the default or choosing a newer version, unless you need a specific version for a specific project.
- The operating system type — this should dynamically adjust to your machine’s operating system. For Windows users, manually adjust to “macOS” or “Linux”.
- The version manager — this will default to “nvm”, which we’ll want to keep. Windows users should confirm that this updates after changing the target operating system.
- The package manager — this will default to “npm”, which we’ll also want to keep.
Type, or copy/paste, each command into your terminal (Windows users should use Git Bash) one at a time and execute them. By the end, the last two commands, node -v and npm -v, should reveal the version numbers of the downloaded resources. You can also use the which node command to show the filepath where Node is installed. If any of these commands is not working, try closing the terminal window and attempting the command again.
Using nvm
nvm offers a number of commands to help us install and manage different versions of Node.js on the same machine. As we saw from the downloads page, one of these commands is install:
// installs the latest subversion of Node 24
nvm install 24
// installs a specific version
nvm install 20.19.5
// installs the latest version and subversion available
nvm install node
Another important command is alias, which allows us to provide an alternative name for a given Node installation. The most commonly used alias is default, to denote which version should be used by default:
// aliases a specific version as "legacy"
nvm alias legacy 20.18.0
// sets a major version as default — if multiple subversions are installed, the newest will be targeted
nvm alias default 24
nvm has two commands for listing out versions of Node: ls is used to list the versions that are installed locally, and ls-remote lists all of the versions that are available to be installed. ls also includes information about aliases and LTS coverage. The following is a truncated form of the output of ls:
$ nvm ls
v20.19.5
-> v24.9.0
system
default -> 24 (-> v24.9.0)
legacy -> 20 (-> v20.19.5)
node -> stable (-> v24.9.0) (default)
stable -> 24.9 (-> v24.9.0) (default)
lts/* -> lts/jod (-> v22.20.0)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8 (-> N/A)
lts/iron -> v20.19.5
lts/jod -> v22.20.0 (-> N/A)
Both commands use colored text in the output to convey additional context. To accommodate color-blindness, these commands offer a --no-colors flag to suppress the coloration: nvm ls --no-colors.
The last command we’ll address is perhaps the most important — having all these versions of Node installed does not do us much good unless we can switch between them! The use command allows us to do exactly that:
// uses a specific version
nvm use 20.18.0
// uses a major version — if multiple subversions are installed, the newest will be targeted
nvm use 24
// uses the version aliased as default
nvm use default
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
Setting Up Node
Install Node on your computer to utilize Node packages - Article
What is Node? Complete Guide to Node.js
Learn what Node is, its meaning in programming, and how Node.js works. Complete definition guide with examples, installation, and real-world uses. - Article
Web Programming on a Chromebook
This article will teach you how to set up for web development on Chromebooks so you can do off-platform web development projects on your Chromebook.
Learn more on Codecademy
- Get an introduction to Node.js—a JavaScript runtime environment typically used to build back-end apps.
- Beginner Friendly.3 hours
- Learn about the different components of a web application's back-end and explore the Node.js JavaScript runtime environment.
- Intermediate.5 hours
- Learn how to build back-end web APIs using Express.js, Node.js, SQL, and a Node.js-SQLite database library.
- Includes 8 Courses
- With Certificate
- Beginner Friendly.30 hours