Getting Started

Nrwl Extensions, or Nx for short, is an extension for the the Angular CLI implementing the monorepo-style development. It is also a collection of runtime libraries, linters, and code generators helping large teams build better with Angular. It is made up of the following packages:

  • @nrwl/schematics:Code generators and command-line tools (this is a dev dependency)
  • @nrwl/nx: Helpers and utilities that can be used by your application (this is a runtime dependency)

Both of these packages are included when creating an Nx Workspace.

Nx has two tags for available versions:

  • latest (current stable version)
  • next (still in development but close!)

Installing Nx

An Nx workspace is an Angular CLI project that has been enhanced to be enterprise ready. Being an Angular CLI project means it will be handy to have the Angular CLI installed globally, which can be done via npm or yarn as well.

npm install -g @angular/cli

or

yarn global add @angular/cli

Note: If you do not have the Angular CLI installed globally you may not be able to use ng from the terminal to run CLI commands within the project. But the package.json file comes with npm scripts to run ng commands, so you can run npm start to ng serve and you can run npm run ng <command> to run any of the ng commands.

After you have installed the Angular CLI, install @nrwl/schematics.

npm install -g @nrwl/schematics

or

yarn global add @nrwl/schematics

If you want to work with the version still in development you can use @nrwl/schematics@next as the package to install.

Creating an Nx Workspace

The @nrwl/schematics library contains a binary script that provides the command create-nx-workspace. That command can be used to create a new Nx Workspace:

create-nx-workspace myworkspacename

This will create a new Nx Workspace using a sandboxed environment...running the Angular CLI ng new command under the hood and using the Nx schematics collection.

Note: You can use ng new if you like, but it relies on globally installed npm packages. And we know that those can be messy. If your globally installed npm packages are in a bad shape, use the create-nx-workspace command.

You can also add Nx capabilities to an existing CLI project by running:

ng add @nrwl/schematics

Next Steps

With a new Nx Workspace set up, you are ready to add apps and libs. Check out the Nx Workspace guide to take the next steps.

Looking for more best practices for enterprise-scale Angular development from the Nrwl team?

Visit Nx Playbook