简体   繁体   中英

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

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM