11 NPM Commands Every Node Developer Should Know.

vyasriday profile image Hridayesh Sharma ・1 min read

1. Create a package.json file

npm init -y # -y to initialize with default values. 

2. Install a package locally or globally

npm i package # to install locally. i is short for install
npm i -g package # to install globally

3. Install a specific version of a package

npm install package@version

4. Install a package as dev dependency

npm i -d package # -d stands for --save-dev i.e install as dev dependency

5.To see all the dependencies of your project

npm list # this will list all the dependencies of the third-party modules as well

6. To see direct dependencies of your project

npm list --depth=0

7. To see the information about a package in your project

npm view package

8. See specific information from package.json of a third-party package like dependencies of the package

npm view package dependencies

9. To check different versions available for a package

npm view package versions

10. Check outdated packages in your project

npm outdated # run with -g flag to check globally

11. To update the packages

npm update

I hope this helps. Let me know if you use any other commands that can be helpful.

Thanks for reading. 😀

Posted on by:

vyasriday profile

Hridayesh Sharma


Javascript Enginner in ♥️ with UX


Editor guide

I would add a 12th - npm audit.
Nice article btw.


Thanks for the appreciation Mirza Leka. :)


What about
npm prune and npm dedupe?


How could you forget - - save


That's no longer required when you run it in a Node project. Running npm i adds it to your package.json as well.


Some comments have been hidden by the post's author - find out more

Code of Conduct Report abuse