To install npm on Windows, download and install Node.js from the official Node.js website. The npm package manager is included in the installation. Follow the installer steps to complete the setup.
For Linux users, install Node.js and npm via your package manager. For Debian and Ubuntu based distributions:
sudo apt update
sudo apt install nodejs npm
For Fedora, CentOS, or RHEL:
sudo dnf install nodejs npm
Verify the installation of Node.js and npm by running:
node -v
npm -v
Once npm is installed, you can start installing packages. For example, to install the React library:
npm install react
You can also create a new Node.js project by initializing a new package.json file:
npm init
npm install
- Install dependencies from your project's package.json file.npm update
- Update all packages to the latest version based on semver.npm run
- Run a command defined in the package.json "scripts" section.If you encounter any issues during the installation, ensure that your system's PATH includes the directory where Node.js and npm were installed. You can also check the npm community and documentation for solutions.
Now that you have npm installed, you're ready to start using it to manage your project's dependencies. For a detailed guide on how to use the npm install <package>
command to add new libraries and tools to your projects, visit our How to Use 'npm install' Command Line Interface page. This guide will provide you with all the information you need to begin installing and managing npm packages effectively.