--run
这将从 package.json 的 "scripts"
对象运行指定的命令。如果缺少 "command"
,它将列出可用的脚本。
¥This runs a specified command from a package.json's "scripts"
object.
If a missing "command"
is provided, it will list the available scripts.
--run
将遍历到根目录并找到一个 package.json
文件来运行命令。
¥--run
will traverse up to the root directory and finds a package.json
file to run the command from.
如果 ancestor-folder/node_modules/.bin
是目录,--run
将当前目录的每个祖级的 ./node_modules/.bin
添加到 PATH
之前,以便从存在多个 node_modules
目录的不同文件夹执行二进制文件。
¥--run
prepends ./node_modules/.bin
for each ancestor of
the current directory, to the PATH
in order to execute the binaries from
different folders where multiple node_modules
directories are present, if
ancestor-folder/node_modules/.bin
is a directory.
--run
在包含相关 package.json
的目录中执行命令。
¥--run
executes the command in the directory containing the related package.json
.
例如,以下命令将运行当前文件夹中 package.json
的 test
脚本:
¥For example, the following command will run the test
script of
the package.json
in the current folder:
$ node --run test
你还可以将参数传递给命令。--
之后的任何参数都将附加到脚本中:
¥You can also pass arguments to the command. Any argument after --
will
be appended to the script:
$ node --run test -- --verbose