Installing Node.js and npm
Learn how to download Node.js, install it on Windows, verify npm, and prepare your system for React development.
1. Introduction
Node.js is a JavaScript runtime that allows JavaScript to run outside a web browser. React development tools use Node.js to perform tasks such as running the development server and building applications.
npm stands for Node Package Manager. It helps install and manage packages required by a project.
2. How Node.js and npm Work Together
Windows Operating System
Environment for development tools
Node.js
Runs JavaScript development tools
npm
Installs and manages packages
Vite
Runs the React development server
React Application
Open and test your application in a browser
Diagram: A simplified development workflow. npm and Vite are separate tools; Vite can be installed as a project dependency through npm.
3. Download Node.js
Download Node.js from its official website. For a new learning environment, choose the version marked LTS (Long-Term Support), unless your project requires a different version.
Node.js Official Download
Choose the Windows installer appropriate for your computer.
Download Node.js ↗Open the Official Website
Visit the Node.js download page using the button above.
Select the LTS Version
Choose the release marked LTS for a stable learning environment.
Select Windows Installer
For most Windows computers, choose the Windows Installer (.msi) that matches your system architecture.
Wait for the Download
Once the installer has downloaded, open it to begin the installation.
4. Install Node.js on Windows
Follow these steps after downloading the Windows installer.
Run the Installer
Open the downloaded .msi file.
If Windows requests permission, review the prompt
before continuing.
node-vXX.X.X-x64.msi
Welcome Screen
Read the installation information and click Next.
Accept the License Agreement
Read the license terms. Accept them if you agree, then continue to the next screen.
Choose the Installation Location
The default installation folder is suitable for most learners. Keep it unless you have a specific reason to change it.
Check the Setup Features
Keep the standard features selected, including npm package manager and the option to add Node.js to PATH when provided by the installer.
node
and npm to run from a terminal.
Click Install
Start the installation and approve any required Windows permission prompts.
Finish the Installation
Wait for the installer to finish and click Finish.
5. Reopen Your Terminal
After installation, close any old Command Prompt, PowerShell, or VS Code terminal windows. Open a new terminal so it can pick up updated environment variables such as PATH.
6. Verify Node.js Installation
Run the following command in the new terminal.
node --version
If Node.js is installed correctly and available on PATH, the terminal displays a version number.
Example Output
v24.x.x
Your installed version may differ. The x
characters here represent version digits in an example.
Node.js Command Recognized
A displayed version indicates that the terminal can find the Node.js executable.
7. Verify npm Installation
Now check whether npm is installed and available.
npm --version
If npm is available, this command displays its version.
Example Output
10.x.x
The output depends on the npm version included with your Node.js installation.
8. Useful npm Commands
These commands will be helpful as you work on React projects.
| Command | Purpose |
|---|---|
npm --version |
Displays the installed npm version. |
npm help |
Displays npm help information. |
npm install |
Installs the dependencies listed by a project. |
npm run |
Lists the available scripts defined in the current project's package.json. |
npm run dev |
Runs the development script if the current project defines it. |
npm install and
npm run dev should normally be run from
the appropriate project directory.
9. Common Errors and Solutions
| Error | Possible Cause | Solution |
|---|---|---|
node is not recognized |
Node.js is missing or its location is not available on PATH. | Check the installation and PATH, then reopen the terminal. |
npm is not recognized |
npm is missing or the terminal cannot find it. | Check the Node.js installation and reopen the terminal. |
npm install fails |
Network, permissions, or dependency errors. | Read the complete error message and check the network and project folder. |
| Old version appears | A different installation may be found first on PATH. | Check the active executable location and remove conflicting PATH entries carefully. |
| Installer cannot run | Incomplete download or an installer that does not match the system. | Download the appropriate installer again from the official website. |
Debugging Tip
First, run node --version and
npm --version in a newly opened terminal.
If either fails, resolve the installation or PATH issue
before creating the React project.
10. Practice Task
Complete this practical exercise before moving to the next lesson.
Task: Verify Your Development Environment
- Download the Node.js LTS installer from the official website.
- Install Node.js using the standard installation options.
- Open a new terminal.
- Run
node --version. - Run
npm --version. - Confirm that both commands display version numbers.
Summary
- Download Node.js from the official website.
- Choose the LTS release for a stable learning environment.
- Install Node.js using the Windows installer.
- npm is normally included with the standard installation.
- Use
node --versionto verify Node.js. - Use
npm --versionto verify npm. - Open a new terminal if the commands are not recognized.