Another Way of Using NPM
As I continue to read through blogs, books, and even watch videos, it seems there are many unknown ways of using NPM; at least to the masses. I wanted to create this quick article to show some of the ways I use NPM, as well as speed up the process of many operations. Seriously, I’m surprised so few people seem to use this, but it’s all there, and any command can be reduced to 1-3 characters.
While there is no real secret here, it’s more or less a PSA to shorten your commands. Many JS projects reference these long commands, but you can save yourself a lot of time removing at least 8 characters for every NPM command you type.
Let’s start looking at the various commands we can start to shorten, as well as how some are helpful:
NPM Common Commands
Here are your most common commands. Every npm user has used these at least once. Now you can see how you can use them all by typing ‘npm’, then with a couple letters the following commands:
Install: i <package>
Global Install: -g i <package>
Save Dependency: -S <package>
Development Dependency Save: -D <package>
Save Optional Dependency: -O <package>
Uninstall: un <package>
As you can already see, these along will save you lots of keystrokes for every command. It really makes you think, “why would anyone want to do it any other way?”
Additional Shorthand Commands
Now for the less common commands, but extremely useful once you know about them:
Install Test: it <package>
List Installed: lis
Outdated (Great for global): out
Even More NPM Goodness
Since we’re on the topic, now’s a great time to point out this great NodeSource article on some other awesome NPM tricks.