How to list all the commands available in package.json?



A package.json can have lot of commands and common ones are npm start, npm test but there are generally more commands.

Is there a way to list all the commands?

Currently I use less package.json but it has too much noise to show.


You can use:

npm run

to list all commands. (Yarn also features similar functionality on yarn run.)

This behavior is made explicit in the help page of npm help run:

This  runs an arbitrary command from a package's "scripts" object.  If no "command" is provided, it will list the available scripts.

To get a quick overview if you have jq installed:

jq .scripts package.json

You can still pipe that subset to less if you need to

jq .scripts package.json | less

Furthermore, you can use tab completion via npm-completion and then you should see a list of possible commands when hitting tab and completes the commands if there is only one option left.

You can set it up temporarily via

source <(npm completion)

Depending on your terminal, you can make it persistent behavior by adding to your relevant config file:

npm completion >> ~/.bashrc
npm completion >> ~/.zshrc

Answered By – k0pernikus

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More