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.
Any script for a Node.js project can be run with
npm run <command>, and "lifecycle" scripts like
test can be run with
You can learn more about run scripts in the npm documentation.