@nrwl/workspace:run-script

Run an npm script using Nx

Options can be configured in angular.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.

Examples

workspace.json:

1"frontend": {
2    "root": "packages/frontend",
3    "targets": {
4        "build": {
5            "executor": "@nrwl/workspace:run-script",
6            "options": {
7                "script": "build-my-project"
8            }
9        }
10    }
11}
nx run frontend:build

The build target is going to run npm run build-my-project (or yarn build-my-project) in the packages/frontend directory.

Caching Artifacts

By default, Nx is going to cache dist/packages/frontend, packages/frontend/dist, packages/frontend/build, packages/frontend/public. If your npm script writes files to other places, you can override the list of cached outputs as follows:

1"frontend": {
2    "root": "packages/frontend",
3    "targets": {
4        "build": {
5            "executor": "@nrwl/workspace:run-script",
6            "outputs": ["packages/frontend/dist", "packaged/frontend/docs"],
7            "options": {
8                "script": "build-my-project"
9            }
10        }
11    }
12}

Options

script (required)

Type: string

An npm script name in the package.json file of the project (e.g., build)