1. npm -v OR npm –version : This gives you the current version of npm installed on your machine.
2. npm init: This command initializes your web project by providing you with a package.json file for your project.
3. npm install #package-name# –save(npm install lodash –save) – This command installs local packages for your project.
4. npm install firstname.lastname@example.org –save: Install specific version of a package onto your project.
5. npm update lodash –save : Update the lodash package in your project.
6. npm install -g nodemon : Install global packages that will be available for usage outside your project
7. npm remove -g nodemon : Remove global packages
8. npm install live-server –save-dev : Install live-server as a dev dependency in your project.
9. npm list : List packages in your project.
10. npm remove gulp –save-dev : Remove dev dependency package from your project.
11. npm remove lodash –save : Remove lodash package from your project.
Versions of packages in package.json
4 represents major version
17 represents minor version
3 represents patch version
1. lodash^4.17.3: Latest minor version of lodash
2. lodash~4.17.3: latest patch version of lodash
3. email@example.com: exact version you’ve described
4. lodash *: latest major version of lodash
These are some few must know npm commands. If you know of other useful npm commands, Kindly comment them below 🙂