Node.js Quick Tips Quick Tips

How to list npm run scripts for a project

< 1 min read

You’re in your terminal and want to use npm run to run one of the scripts for the Node.js project you’re working on. The only problem is you can’t quite remember the script name.

Instead of digging inside the package.json for the script name, you can list all the run scripts available for a Node.js project from the command line by executing npm run without a command. I find this a super handy way to avoid context switching and disrupting the flow of what I’m doing in the terminal.

Screenshot of a terminal with the output from the command npm run

Any script for a Node.js project can be run with npm run <command>, and "lifecycle" scripts like test can be run with npm <command>.

You can learn more about run scripts in the npm documentation.

Original tweet