添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
曾经爱过的电影票  ·  年度市場數據·  1 月前    · 
温柔的汽水  ·  SUPER GT ...·  2 月前    · 
沉着的生菜  ·  python3 ...·  3 月前    · 
跳到主内容

pnpm run

Aliases: run-script

运行一个在 package 的 manifest 文件中定义的脚本。

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 ! 很简单吧? 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).

运行多个脚本

你可以使用正则表达式来替代脚本名称从而同时运行多个脚本。

pnpm run "/<regex>/"

Run all scripts that start with watch: :

pnpm run "/^watch:.*/"

详细说明

In addition to the shell’s pre-existing PATH , pnpm run includes node_modules/.bin in the PATH provided to scripts . 这意味着,只要你安装了一个包,你就可以像常规命令一样在脚本中使用它。 For example, if you have eslint installed, you can write up a script like so:

"lint": "eslint src --fix"

And even though eslint is not installed globally in your shell, it will run.

For workspaces, <workspace root>/node_modules/.bin is also added to the PATH , so if a tool is installed in the workspace root, it may be called in any workspace package's scripts .

运行环境

pnpm 会自动为执行的脚本创建一些环境变量。