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
Crashes at end of ng add @nrwl/angular
...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)
npm init nx-workspace myworkspaceng add @nrwl/angularrelevant information about my setup:
npm init nx-workspace myworkspace - 7.6.2same problem, when running tslint:
Could not find custom rule directory: node_modules/@nrwl/workspace/src/tslint
I updated from "@nrwl/nx": "7.8.6" to "@nrwl/nx": "7.8.7".
It looks like an older version of Nx was used.
Please use npm init nx-workspace@latest myworkspace to make sure you get the latest version.
You only need to add @nrwl/angular when using Nx 8+
@FrozenPandaz , thanks very much. That worked a treat. I'll use that for now.
Technically however, this is still a bug - as all your docs don't mention @latest. Would you mind leaving this issue open, so that I can remain subscribed and know when it has been patched?
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 @FrozenPandaz i tried the command you mentioned. I still get the same error.
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?
@tdekoekkoek will you provide some more information about your environment? Such as:
Neither npx create-nx-workspace@latest myworkspace
nor npm init nx-workspace@latest myworkspace works:

having same issue as @ph55
I have the same issue I can't create a new workspace neither npm init nx-workspace@latest nor npx create-nx-workspace.
I am running from a windows machine and the latest node version 12.7.0
Found workaround: npm i -g @nrwl/workspace - after installing workspace globally
npx create-nx-workspace myworkspace works.
hey guys @sergidt , @ph55 yep... had to install @nrwl/workspace first
If you are trying to create work-space
Thanks to @FrozenPandaz for the temporary advice:
Please use npm init nx-workspace@latest myworkspace
As of Nrwl Nx version 8.5 this is no longer an issue.
npm init nx-workspace myworkspace
Now works just fine.
Closing issue...
For me, install nx cli globally works.
npm install -g @nrwl/cli
I have still this error.
Installed nx for the first time with:
npm install -g @nrwl/cli
source: https://nx.dev/web/guides/cli
After that I try whats @vsavkin write:
https://github.com/nrwl/nx/issues/1306#issuecomment-495283429
npx create-nx-workspace@latest my-ui-admin --preset=empty
ng g app angularapp --e2e-test-runner=proctractor
Because I want a app with protractor.
After last command I get the error:
An unhandled exception occurred: Schematic "app" not found in collection "@nrwl/workspace".
I tried it also with:
npm init nx-workspace myworkspace
-> empty workspace
-> angular-cli
and after that the ng g add command, but with same result.
My System infos:
Mac: 10.15.2
Nx Version: 8.11.2
Angular CLI: 8.3.14
Node: 10.18.0
OS: darwin x64
rough start ;-)
Update:
After reading: https://github.com/nrwl/nx
I get it work:
npm install --save-dev @nrwl/angular
nx g @nrwl/angular:app myapp --e2e-test-runner=proctractor
Only if I install @nrwl/workspace locally, then it works. It's right? Why @nrwl/workspace not appear in docs?
Similar error here, the applications run but I cant create any library
➜ nx g @nrwl/angular:lib --directory=ng models --dry-run
Cannot find module '@nrwl/workspace/src/utils/rules/workspace'
I'm having the same issue as @duard
> nx g @nrwl/angular:app dev-admin-app --dry-run
Cannot find module '@nrwl/workspace/src/utils/rules/workspace'
Require stack:
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\angular\src\schematics\init\init.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\angular\src\schematics\application\application.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\tao\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\tao\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\tao\src\commands\generate.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\tao\index.js
- C:\Repos\pa\pa_service_api\node_modules\@nrwl\cli\bin\nx.js
- C:\Users\Gamer\AppData\Roaming\npm\node_modules\@nrwl\cli\lib\init-global.js
- C:\Users\Gamer\AppData\Roaming\npm\node_modules\@nrwl\cli\bin\nx.js
EDIT: Running npm install after updating to nrwl/nx 9.1.14 resolved this issue.
@michael-golden I'm using Nx with Angular, and I fixed it doing :
nx update --all --force
ng add @nrwl/angular
fixed it for me.
@gqchishti
I had this problem again after selecting Empty Workspace when creating with latest Nx.
Your solution fixed it for me. Thanks.
Reviving the same error! 👎
[error] Error: Could not find module "@nrwl/workspace" from ".../x-workspace".
at Object.resolve (/home/x/node_modules/@angular-devkit/core/node/resolve.js:154:11)
at NodeModulesEngineHost._resolvePackageJson (/home/x/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:28:21)
at NodeModulesEngineHost._resolveCollectionPath (/home/x/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:69:40)
at NodeModulesEngineHost.createCollectionDescription (/home/x/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:115:27)
at SchematicEngine._createCollectionDescription (/home/x/node_modules/@angular-devkit/schematics/src/engine/engine.js:147:40)
at SchematicEngine.createCollection (/home/x/node_modules/@angular-devkit/schematics/src/engine/engine.js:140:43)
at NewCommand.getCollection (/home/x/node_modules/@angular/cli/models/schematic-command.js:128:35)
at NewCommand.initialize (/home/x/node_modules/@angular/cli/models/schematic-command.js:44:37)
at async NewCommand.validateAndRun (/home/x/node_modules/@angular/cli/models/command.js:124:9)
at async Object.runCommand (/home/x/node_modules/@angular/cli/models/command-runner.js:186:24)
I had the same issue. After removing a rogue package.json, package-lock and node_modules that contained an older version of @nrwl/workspace folder in a parent directory, of my current working directory, the command worked as expected.
sorry I don't have the exact details...as I cleaned up the files were gone.
Found workaround:
npm i -g @nrwl/workspace- after installing workspace globally
npx create-nx-workspace myworkspaceworks.
This helped me move forward. Then I got another error saying module 'typescript' was not found. Did "npm i -g typescript" then tried "npx create-nx-workspace myworkspace" again and this time it worked! Thnx alot :)
I happened to come across this project today and it looked like a fantastic way to speed up my builds. I got the same errors as many others are describing though.
Running npm install @nrwl/nx-cloud && ng g @nrwl/nx-cloud:init on a clean install resulted in:
````
An unhandled exception occurred: Cannot find module '@nrwl/workspace'
Require stack:
After starting to dig deeper it seems that maybe the onboarding for https://nx.app/orgs assumes that you've already got a bunch of other things in play. I didn't have any of those though so would be great to have a few more cues on where to start.
Looking forward to the chance to actually use this as the videos look super promising.
❯ nx generate @nrwl/angular:application appName works for me.
Most helpful comment
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?