pnpm run
Aliases: run-script
Runs a script defined in the package's manifest file.
Examples
Let's say you have a watch
script configured in your package.json
, like so:
"scripts": {
"watch": "webpack --watch"
}
You can now run that script by using pnpm run watch
! Simple, right?
Another thing to note for those that like to save keystrokes and time is that
all scripts get aliased in as pnpm commands, so ultimately pnpm watch
is just
shorthand for pnpm run watch
(ONLY for scripts that do not share the same name
as already existing pnpm commands).
Running multiple scripts
You may run multiple scripts at the same time by using a regex instead of the script name.
pnpm run "/<regex>/"
Run all scripts that start with watch:
:
pnpm run "/^watch:.*/"
Details
In addition to the shell’s pre-existing PATH
, pnpm run
includes
node_modules/.bin
in the PATH
provided to scripts
. This means that so
long as you have a package installed, you can use it in a script like a regular
command. For example, if you have eslint
installed, you can write up a script
like so:
"lint": "eslint src --fix"