16

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?

1
  • In addition to the answer given by duncanhall below, here's a blog post I found helpful when starting out with NPM scripts - they're a lot more flexible than you might first imagine: blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool Commented Apr 27, 2016 at 10:43

1 Answer 1

30

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.