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!)
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/cli
yarn global add/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.jsonfile 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
npm install -g/schematics
yarn global add/schematics
If you want to work with the version still in development you can use
@nrwl/schematics@nextas the package to install.
Creating an Nx Workspace
@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:
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 newif 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
You can also add Nx capabilities to an existing CLI project by running:
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.