Run a package script
Destructive
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Lists the scripts declared by a project, then runs one through npm with the project-local binaries and environment available on the script path.
nodenpmscripts
Confirmation required
This recipe is destructive and requires confirmation — confirm you understand the impact before running any command below.
Parameters
Exact package.json script name to run.
Commands
Review declared scripts before choosing one to execute
npm runExecute the selected project-defined command
npm run "<script>"Verification
npm pkg get scriptsnpm prints the project scripts; use the selected script's output and exit status to judge its result.
Undo
Not undoable
Package scripts can perform arbitrary project-specific changes, so no universal undo command is possible.
Pitfalls
- Inspect the selected script and any pre- or post-script hooks before running code from an untrusted project.
- The recipe cannot predict files, services, or external systems changed by a project-defined script.