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.