0

I tried the below, but got some errors.

  1. create a Nx workspace: npx create-nx-workspace@latest myworkspace, and select to use Angular CLI
  2. generate angular app: yarn add --dev @nrwl/angular && yarn ng g @nrwl:angular:app myapp-ng I can see a angular.json for the workspace setup similarly as Angular CLI, and yarn start/build all works
  3. add react capability: yarn add -D @nrwl/react
  4. generate another react app: yarn ng g @nrwl/react:app myapp-react but I got the below error saying Nx workspace not recognized.

I guess it's trying to find the workspace config instead from workspace.json (an empty Nx workspace has such setup).

Is this a bug in Nx or is it a supported case to include both Angular and React in one workspace? I can find some blogs/docs about it though...

UPDATE:

Okay, just realized that I made a mistake here :(

At step 4, I was running yarn nx g ... instead of ng g .... Then there's a warning as below when using nx command in a NG CLI workspace:

yarn nx g @nrwl/react:app react2 --dry-run
yarn run v1.12.3
$ nx g @nrwl/react:app react2 --dry-run

>  NX   NOTE  Nx didn't recognize the command, forwarding on to the Angular CLI.

the react app can actually be created successfully using NG CLI. And, I think the warning makes sense.

Roy Ling
  • 1,592
  • 1
  • 14
  • 31

1 Answers1

1

What version of NX are you using? Everything should work well, look at the NX example: https://github.com/nrwl/nx-examples

It uses: "@nrwl/angular": "8.4.0", as well as "@nrwl/react": "8.4.0", and consists of two apps:

  1. Carts (React): Carts app - React
  2. Products (Angular): Products App - Angular
Chris
  • 652
  • 1
  • 7
  • 22
  • I figured out that it's my mistake and that's only a warning note instead of errors. Sorry for the mistake and thanks for your answer, especially the link to the example repo. I guess the warning is thrown when using `nx` command in a NG CLI workspace, right? I already updated the OP. – Roy Ling Nov 27 '19 at 06:07