NPM Cheat Sheet

Node Package Manager (NPM) is an awesome tool that installs nodeJS programs. It also makes it easier to specify and link dependencies. All nodeJS developers have used NPM one time or another. If you haven’t then you must be some sort of genius. I’ve put together my own personal cheat sheet of useful NPM commands that I’ll kindly share with you.

Search all NPM Packages

npm search

This displays all the available packages. There are also online tools that can help you search for NPM packages. Nipster sorts all packages by their GitHub rating. npmsearch sorts packages by relevance and downloads.

What’s installed on your system

npm ls installed

This command shows what’s on your system and also what’s available in the registry.

Updating Packages

npm update

This command will search for new versions of all the packages installed. If there’s a newer version it’ll install it and points dependent packages at the new version if it satisfies their dependency. It will also remove the old versions if no other package names them as a dependency.

Create your own package.json

npm init

When this command is run within a folder, you’ll be asked a few questions before the package.json is written out.

Here are also some useful links I keep handy:

1 Comment

Thank you . This is useful information for new npm admirer like me . However, I would hope that you can provide a ready to use examples to demo some cool things about npm. So cheatsheets with dynamic demo samples that allow us to experience the
cool features.
Two particular useful features : 1.the ability of npm to install modules that may have conflicting dependencies
i.e. handle mutliple versions of the same thing at the same time. This is something that really stands out, a lot of installation tool will not allow that.

2.shinkrage to force the dependencies which is very important for production code.
If we just playaround and develop code, I do not care what versions I pull down, if things are stable , the newer the best.
However for production, we need to have a “controlled environment” so that we know what exacts versions are shipped and to be able to support the code and have a consistent testing behavior.
Thank you again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math      

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: