Closed uspasojevic96 closed 3 years ago
Same issue here - very discouraging.
OS : darwin x64
npm : 6.14.12
nx : Not Found
@nrwl/angular : 12.3.3
@nrwl/cli : 12.3.3
@nrwl/cypress : 12.3.3
@nrwl/devkit : 12.3.3
@nrwl/eslint-plugin-nx : 12.3.3
@nrwl/express : Not Found
@nrwl/jest : 12.3.3
@nrwl/linter : 12.3.3
@nrwl/nest : 12.3.3
@nrwl/next : Not Found
@nrwl/node : 12.3.3
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.3.3
@nrwl/web : Not Found
@nrwl/workspace : 12.3.3
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.2.4```
I'm seeing this on a new Angular 12 + Nest project as well. Kind of aggravating. I'd love to know what is the difference here because ng serve
works on a new Angular 12 CLI project no problem.
Hey! :)
Thank you for raising the issue. I'll investigate to find a fix that will allow this to work with no problems.
However, in the meantime, there is a workaround:
node_modules
package-lock.json
npm install
You should now be able to run nx build
for both the NestJS and Angular apps with no problems.
P.S.
If you're curious why this happens:
@nrwl/nest
depends on @nrwl/node
which uses Webpack 4.
Since Angular 12, Angular uses Webpack 5.
The initial install of additional packages when you add Angular support to a workspace that already has Webpack 4 in it, will find Webpack already installed, and will not install Webpack 5.
Therefore, deleting the node_modules
and the package-lock.json
and running npm install
allows the correct version of Webpack to be resolved and installed for Angular 12.
So, in theory, if we were to add Angular first and NestJS second then it should work without even needing to delete node_modules
and package-lock.json
, right?
Yes, that is correct.
I've tried that flow locally and it works perfectly.
Based on the two solutions provided above:
https://github.com/nrwl/nx/issues/5682#issuecomment-842320300
https://github.com/nrwl/nx/issues/5682#issuecomment-842407479
I'm going to close this issue.
If the problem persists and these solutions do not work, please let us know!
@Coly010 The workarounds are nice, but I would argue this isn't shouldn't be closed because the bug still exists. Users creating new angular + nest projects from the nx schematic will not be able to use ng serve
without applying one of these workarounds manually.
Is it not possible to update the schematic to automatically apply the #2
workaround (install angular then nest)?
Hi @jadengis !
The real fix here is to upgrade the @nrwl/node
package to use Webpack 5, and that work is currently underway.
However, I'll take a look and see if we can change the Angular+Nest schematic to install Angular then Nest.
If you're interested, you could also take a stab at creating a PR that makes this change :)
Workaround doesn't work with yarn @Coly010 😢
Upgrading from 12.3.6 to 12.3.5 resulted in the main webpack (root of node_modules) being v4 again not 5 anymore...
Node : 14.16.0
OS : darwin x64
yarn : 1.22.10
nx : Not Found
@nrwl/angular : 12.6.5
@nrwl/cli : 12.6.5
@nrwl/cypress : 12.6.5
@nrwl/devkit : 12.6.5
@nrwl/eslint-plugin-nx : 12.6.5
@nrwl/express : Not Found
@nrwl/jest : 12.6.5
@nrwl/linter : 12.6.5
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 12.6.5
@nrwl/nx-cloud : 12.3.6
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.6.5
@nrwl/web : 12.6.5
@nrwl/workspace : 12.6.5
@nrwl/storybook : 12.6.5
@nrwl/gatsby : Not Found
typescript : 4.3.5
@uspasojevic96 I'm noticing the same, myself still. I'm following your @nrwl
package versions, but do you know what Angular package versions you had?
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Fresh Angular app does not build with
nx build app-name
Expected Behavior
Fresh Angular app should be able to build when it's been freshly generated
Steps to Reproduce
nx build
for the generated Angular appFailure Logs
Environment
Edit
I don't know why
nx report
isn't detecting nx: