What is Node.js
What is NPM
NPM facilitates the sharing and utilization of open-source packages among web developers, serving as a command-line utility for package installation, dependency management, and version control within projects.
Key Components of NPM:
- Website: The official NPM website offers a repository of packages for projects. Users can create and manage profiles to access a wide range of packages.
- Command Line Interface (CLI): The CLI allows interaction with NPM packages and repositories directly from the terminal of your computer.
How to Install Node.js and NPM on Windows?
Step 1: Downloading the Node.js Installer
To begin, visit the official Node.js website and navigate to the Downloads section. Opt for the “LTS” (Long-Term Support) version, ensuring stability and reliability. Choose the appropriate installer based on your Windows operating system, whether it’s 32-bit or 64-bit.
Step 2: Running the Installer
After downloading the installer, locate the file and initiate it by double-clicking. In case of a security prompt, grant permission to proceed. The Node.js Setup Wizard will appear, guiding you through the installation process. We recommend accepting the default settings, including the installation location. This ensures a smooth setup without any complications.
Step 3: Verifying the Installation
Once the installation completes, the Node.js Setup Wizard will display a “Completed” message. Ensure that the checkbox for installing the necessary tools for Node.js application development is checked. To confirm a successful installation, open the Command Prompt and run the following commands:
- To check the Node.js version:
- To verify the npm installation:
If you see version numbers displayed, it means Node.js and npm have been successfully installed on your Windows system.
Advanced: Working with Node Version Manager (NVM)
NVM, the Node.js Version Manager, simplifies the installation and management of different Node.js versions. It allows easy switching between versions while preserving globally installed packages specific to each version. On the other hand, NPM, the Node Package Manager, is a tool used for installing libraries, plugins, frameworks, and applications. It facilitates the process of adding and managing dependencies within your Node.js projects.
To manage multiple Node.js versions using NVM, follow these steps:
- Download NVM for Windows.
- Select the nvm-setup.zip file.
- Unzip the file and run the installer.
- Verify the successful installation of NVM by opening a new command prompt and typing “nvm”.
- Install Node.js using NVM by executing the command “nvm install <version>”. Replace “<version>” with the desired Node.js version or use “latest” for the latest stable version.
- Check the installed Node.js version by typing “node -v”.
- (Optional) If you wish to install another version of Node.js, repeat Step 5 with a different version.
- View the list of installed Node.js versions by running the command “nvm list”.
- To use a specific Node.js version, execute “nvm use <version>” with the desired version.
nvm install <version>
nvm use <version>