xx
.md

npm_run

npm_run runs a script from project-root package.json as npm run <script> -- <args...>. It uses npm bundled with managed Node.js, registers a root task, and returns its dependency.

Project-root package.json must be a regular, non-symlink file after dependencies finish.

Arguments

ArgumentRequiredDescription
scriptYesNon-empty package script name that does not begin with -.
argsNoString arguments passed to the script after --. Defaults to [].
depsNoDependencies activated before the script, in list order. Defaults to [].

Examples

Run a package script

load("@[email protected]", "npm_run")

npm_run("test")

Pass script arguments

load("@[email protected]", "npm_run")

npm_run("test", args=["--runInBand"])

Install before building

load("@[email protected]", "npm_install", "npm_run")

install = npm_install(frozen_lockfile=True)
npm_run("build", deps=[install])

Without deps=[install], both root tasks may run concurrently.