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

Grumpy ol' Bear

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?

duncanhall

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to create custom cli commands for own npm package

From Dev

How can I update the protractor npm module in node.js?

From Dev

Can I modify and publish npm modules (node.js)?

From Dev

How do I create a custom command to replace `gulp` or `npm run`?

From Java

How can I completely uninstall nodejs, npm and node in Ubuntu 14.04

From Dev

How can i install npm in ubuntu to run less js

From Dev

How can i install npm in ubuntu to run less js

From Dev

Where should I store cache of a custom CLI npm module?

From Java

How to uninstall npm modules in node js?

From Dev

How can I exclude @angular/cli from npm-install process in a Docker image creation process?

From Dev

node npm from maven looks npm-cli.js in project directory

From Dev

NPM: npm-cli.js not found when running npm

From Dev

NPM: npm-cli.js not found when running npm

From Dev

How can I run a Node 6 npm package in a Node 5.6.0 environment?

From Dev

Node.js - Can I install NPM package on a PhoneGap / Cordova application?

From Dev

How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

From Dev

How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

From Dev

How can I run mocha with npm script?

From Java

How can I update npm on Windows?

From Dev

How can I use commander (npm) with TypeScript?

From Dev

How can I run NPM without sudo?

From Dev

How can I install npm on 17.10?

From Dev

How can I make this npm project works?

From Dev

How can I update npm package on github

From Dev

How add commands to cygwin - npm

From Dev

How to update npm and node

From Dev

How can i add my custom npm package to TypeScript Definition manager?

From Java

How vue.js cli command "npm run serve" work

From Dev

How can I get node-sass watch and live reload to work from a single NPM script?

Related Related

  1. 1

    How to create custom cli commands for own npm package

  2. 2

    How can I update the protractor npm module in node.js?

  3. 3

    Can I modify and publish npm modules (node.js)?

  4. 4

    How do I create a custom command to replace `gulp` or `npm run`?

  5. 5

    How can I completely uninstall nodejs, npm and node in Ubuntu 14.04

  6. 6

    How can i install npm in ubuntu to run less js

  7. 7

    How can i install npm in ubuntu to run less js

  8. 8

    Where should I store cache of a custom CLI npm module?

  9. 9

    How to uninstall npm modules in node js?

  10. 10

    How can I exclude @angular/cli from npm-install process in a Docker image creation process?

  11. 11

    node npm from maven looks npm-cli.js in project directory

  12. 12

    NPM: npm-cli.js not found when running npm

  13. 13

    NPM: npm-cli.js not found when running npm

  14. 14

    How can I run a Node 6 npm package in a Node 5.6.0 environment?

  15. 15

    Node.js - Can I install NPM package on a PhoneGap / Cordova application?

  16. 16

    How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

  17. 17

    How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

  18. 18

    How can I run mocha with npm script?

  19. 19

    How can I update npm on Windows?

  20. 20

    How can I use commander (npm) with TypeScript?

  21. 21

    How can I run NPM without sudo?

  22. 22

    How can I install npm on 17.10?

  23. 23

    How can I make this npm project works?

  24. 24

    How can I update npm package on github

  25. 25

    How add commands to cygwin - npm

  26. 26

    How to update npm and node

  27. 27

    How can i add my custom npm package to TypeScript Definition manager?

  28. 28

    How vue.js cli command "npm run serve" work

  29. 29

    How can I get node-sass watch and live reload to work from a single NPM script?

HotTag

Archive