Node.js is a JavaScript runtime environment that enables server-side scripting, paired with npm, its built-in package manager, for managing project dependencies.
Table of Contents
Steps to Install Node.js and npm Using an MSI Installer
- Visit Node.js’s official download page and choose the MSI installer for your system (LTS version recommended for stability). Save it to a location on your computer.
- Double-click the MSI file.
- Follow the prompts, accepting the license agreement and default settings.
- Ensure the option to add Node.js to the system PATH is enabled.
- Open the command prompt and type:
node -v npm -v
These commands display the installed versions of Node.js and npm, confirming they’re set up correctly.
Install with Other Package Managers
Use Chocolatey
choco install -y nodejs.install
This automates the installation process with Chocolatey, a Windows package manager.
Use WinGet
winget install OpenJS.NodeJS.LTS
This downloads and installs the latest LTS version silently.
Advanced Configuration with nvm for Windows
Node Version Manager (nvm) is a handy tool for managing multiple versions of Node.js:
- Download nvm-windows and run the installer.
- Install Node.js versions:
nvm install <version>
- Switch between versions:
nvm use <version>
Ensure the PATH updates with the correct Node.js version paths.
Test Node.js
- Create a file hello.js with:
console.log("Hello, world!");
- Run the script:
node hello.js
This verifies that Node.js executes JavaScript correctly.
Important Considerations
- Verify PATH includes Node.js and npm directories:
echo %PATH%
- Dependencies: Some npm packages require Python or Visual Studio tools, which can be installed using the npm prompt.
By following these steps, you can install and configure Node.js on Windows efficiently, reducing potential errors during development