nx: New Workspace + add Angular = Could not find module "@nrwl/workspace"
Expected Behavior
Creating new workspace via npm, add Angular tooling, and generate Angular app should use latest version and not crash.
This relates to ticket #1497, but is not the same
Current Behavior
Crashes at end of ng add @nrwl/angular
Failure Information
…error received during ng add @nrwl/angular install:
Installed packages for tooling via npm.
Could not find module "@nrwl/workspace" from "...\myworkspace".
Error: Could not find module "@nrwl/workspace" from "...\myworkspace".
at Object.resolve (...\myworkspace\node_modules\@angular-devkit\core\node\resolve.js:141:11)
at NodeModulesEngineHost._resolvePackageJson (...\myworkspace\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:28:21)
at NodeModulesEngineHost._resolveCollectionPath (...\myworkspace\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:69:40)
at NodeModulesEngineHost.createCollectionDescription (...\myworkspace\node_modules\@angular-devkit\schematics\tools\file-system-engine-host-base.js:111:27)
at SchematicEngine._createCollectionDescription (...\myworkspace\node_modules\@angular-devkit\schematics\src\engine\engine.js:147:40)
at SchematicEngine._createCollectionDescription (...\myworkspace\node_modules\@angular-devkit\schematics\src\engine\engine.js:158:48)
at SchematicEngine.createCollection (...\myworkspace\node_modules\@angular-devkit\schematics\src\engine\engine.js:140:43)
at AddCommand.getCollection (...\myworkspace\node_modules\@angular\cli\models\schematic-command.js:123:35)
at AddCommand.runSchematic (...\myworkspace\node_modules\@angular\cli\models\schematic-command.js:262:50)
at AddCommand.executeSchematic (...\myworkspace\node_modules\@angular\cli\commands\add-impl.js:134:31)
at AddCommand.run (...\myworkspace\node_modules\@angular\cli\commands\add-impl.js:105:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
Steps to Reproduce
npm init nx-workspace myworkspace- From new workspace folder…
ng add @nrwl/angular
Context
relevant information about my setup:
- version of Nx used: latest provided by
npm init nx-workspace myworkspace- 7.6.2 - version of Angular CLI used: defined by nx in workspace - 7.3.1, but my global is 8.0.3
- Node: 10.14.0
- OS: win32 x64
- I’ve created a demo repo for you to see what was created by running the above commands on my Windows laptop.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 29 (1 by maintainers)
This keeps haunting me. I’ve created a brand new workspace with the latest nx as far as I know and I keep getting this error. Is there any fix?
I have still this error. Installed nx for the first time with:
source: https://nx.dev/web/guides/cli
After that I try whats @vsavkin write: https://github.com/nrwl/nx/issues/1306#issuecomment-495283429
Because I want a app with protractor.
After last command I get the error:
I tried it also with:
-> empty workspace -> angular-cli
and after that the ng g add command, but with same result.
My System infos:
rough start 😉
Update: After reading: https://github.com/nrwl/nx I get it work:
@michael-golden I’m using Nx with Angular, and I fixed it doing :
nx update --all --force❯ nx generate @nrwl/angular:application appNameworks for me.Found workaround:
npm i -g @nrwl/workspace- after installing workspace globallynpx create-nx-workspace myworkspaceworks.ng add @nrwl/angularfixed it for me.having same issue as @ph55
It looks like an older version of Nx was used.
Please use
npm init nx-workspace@latest myworkspaceto make sure you get the latest version.You only need to add
@nrwl/angularwhen using Nx 8+hey guys @sergidt , @ph55 yep… had to install @nrwl/workspace first