npm stands for Node Package Manager, which is the default package manager for the JavaScript runtime environment Node.js. It is a popular tool among developers due to its abilities to manage all the packages and modules for Node.js, and also manage their associated dependencies.
npm comes pre-installed with Node.js, so if you install Node.js, you automatically get npm installed on your computer.
Here’s a simple way to use npm:
- After you have Node.js installed on your computer, open your command prompt (or Terminal for Mac users).
- Check if Node.js is installed correctly by typing `node -v`. This will show the version of Node.js installed.
- Similarly, check npm by typing `npm -v`.
Basic npm commands:
1. `npm init`: This command is used to create a new npm project and starts by creating a `package.json` file. It will prompt you to enter some information such as the app’s name, description, version, author, etc. If you want to skip the questionnaire, you can use `npm init -y`.
1. `npm install
1. `npm install`: This command will install all the dependencies that are defined in the `package.json` file.
1. `npm uninstall
1. `npm update`: This command will update all the packages defined in the `package.json` file to their latest version.
Remember, each npm package has its own set of documentation which you should refer to as it explains how to use the package in the project.