Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js & npm: How can I create custom npm cli commands?

Tags:

node.js

npm

Say for example that I quite often use npm list -g -depth 0 as command, and I'd like to alias it with npm listC or npm list -c1.

How do I do that?

like image 992
Grumpy ol' Bear Avatar asked Apr 27 '16 10:04

Grumpy ol' Bear


1 Answers

You can use npm scripts to create shortcuts for custom commands.

In your package.json you might have:

{
    "scripts": {
        "listC": "npm list -g depth 0"
    }
} 

And you could then run it with npm run listC.

like image 162
duncanhall Avatar answered Oct 19 '22 13:10

duncanhall