nx/docs/shared/cli-overview.md
Isaac Mann ce56206373
docs(misc): add CLI overview page and misc docs updates (#2734)
* docs(docs): remove migration articles from menu

* docs(nest): fix typo

* docs(docs): fix typo in e2e docs

* docs(docs): cli-overview

Co-authored-by: Isaac Mann <isaacplmann+git@gmail.com>
2020-03-27 06:45:19 -05:00

2.3 KiB

Nx CLI

The Nx CLI allows you to interact with your workspace in many ways, including operating on your code with builders, modifing or creating code with schematics and other tasks.

Run Builders

nx run launches builders to perform actions on your code like testing, building or linting.

  • nx run
    Syntax: nx run [project]:[command]
    Example: nx run my-app:build

Since there are several frequently run builders, there's a shorthand syntax for these:

  • nx build
    Syntax: nx build [project]
    Long form: nx run [project]:build
    Example: nx build my-app
  • nx lint
    Syntax: nx lint [project]
    Long form: nx run [project]:lint
    Example: nx lint my-app
  • nx serve
    Syntax: nx serve [project]
    Long form: nx run [project]:serve
    Example: nx serve my-app
  • nx e2e
    Syntax: nx e2e [project]
    Long form: nx run [project]:e2e
    Example: nx e2e my-app
  • nx test
    Syntax: nx test [project]
    Long form: nx run [project]:test
    Example: nx test my-app

Generate Schematics

nx generate runs schematics to create or modify code given some inputs from the developer.

  • nx generate
    Syntax: nx generate [plugin]:[schematic-name] [options]
    Example: nx generate @nrwl/express:app api

Workspace schematics are schematics that you have created specifically for your own workspace. They are executed using the nx workspace-schematic command.

  • nx workspace-schematic
    Syntax: nx workspace-schematic [schematic-name] [options]
    Example: nx workspace-schematic create-new-route contact-us

More Commands

nx affected allows you to run builders only on projects that have been affected by a particular code change.

  • nx affected
    Syntax: nx affected --target=[command]
    Example: nx affected --target=test

nx dep-graph launches a visual graph of the dependencies between your projects.

nx affected:dep-graph launches the dependency graph with all affected projects highlighted.

nx list lists all installed and available plugins.