Add Angular Material to Nx Workspace

If you created the an empty workspace you don't have angular.json, you will have a workspace.json, which is almost identical I think.

Assuming that you have already generated an agular app:

  1. Install the angular material lib: yarn add @angular/material

  2. To see the avaible commands from the nx console: nx list @angular/material enter image description here

  3. To add angular material to the default project: nx generate @angular/material:ng-add enter image description here

PS. Probably it will thrown an error on nx not found/installed. yarn add -g @nrwl/cli. I think is possible to add angular material to another project, didn't try that yet

https://github.com/nrwl/nx/issues/3779#issuecomment-751136586


npx nx g @angular/material:ng-add --project=my-project-name is the command you need to run in your Nx Workspace.

Do not forget to include the project name or you will see errors.

Additionally, If you continue having errors try by answering no to the questions about Set up global Angular Material typography styles and Set up browser animations for Angular Material.

Disclaimer: Another member already answered correctly in the comments but I think a simple answer like this one should be pinned.