npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Ability to add own global sub commands to npm CLI

I recently had the idea that it would be nice if I could add npm subcommands by my own in form of a plugin to improve my work with NPM on my machine.

I use a package called sort-package-json daily to sort my keys in package.json. I’m not aware that npm i does a similar thing but I would like to extend that package to sort package.json to my own style. So for this, it would be nice if I could add a subcommand like npm pretty that would call this script and prettifies my package.json.

I think this could also give other programmers the ability to add often used command directly to the NPM CLI without typing it in scripts again and again for each project.