Nx: Failed to create workspace

Created on 19 Jan 2018  ·  7Comments  ·  Source: nrwl/nx

Did a clean installation of NX and CLI, per instructions on web site:

npm install -g @nrwl/schematics 
npm install -g @angular/cli

Versions are

@angular/[email protected]
@nrwl/[email protected]

I run create-nx-workspace demo and it fails with

Creating a sandbox with the CLI and Nx Schematics...
[fsevents] Success: "/private/var/folders/zt/gn3lrvp9609gz_qgcc6c17mr0000gn/T/tmp-87824yujjV3jYkT1Y/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
Cached binary found at /Users/Ward/.npm/node-sass/4.7.2/darwin-x64-57_binding.node
Binary found at /private/var/folders/zt/gn3lrvp9609gz_qgcc6c17mr0000gn/T/tmp-87824yujjV3jYkT1Y/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine
added 1009 packages in 24.565s
ng new "ngrx-data" --collection=@nrwl/schematics
module.js:540
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'

No directory created. No obvious traces of activity left behind on disk.

Running node v.8.9.4 and npm v.5.6.0 on Mac OS High Sierra

Most helpful comment

I had the same issue, seems to be related to stuff discussed here https://github.com/angular/angular-cli/issues/9194.

I found the following workaround, though:

npm un -g @angular-devkit/core @angular-devkit/schematics @schematics/angular @nrwl/schematics @angular/cli
npm i -g @angular-devkit/core
npm i -g @angular-devkit/schematics
npm i -g @schematics/angular
npm i -g @nrwl/schematics
npm i -g @angular/cli

Once finished your global tree should look something like this:

~$ npm -g ls --depth=0
~/.nvm/versions/node/v8.9.1/lib
├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @nrwl/[email protected]
├── @schematics/[email protected]
└── [email protected]

After that I ran:

ng new "PROJECT_NAME" --collection=@nrwl/schematics # same as what create-nx-workspace does, but I still had issues when running create-nx-workspace

And the project was successfully created.

You will then need to cd into the created project and run:

npm i -D @angular-devkit/core

To be able to generate apps, libs, components, etc.

__Environment:__

  • Mac OS X Sierra 10.12.6 (16G1036)
  • Node 8.9.1
  • NPM 5.6.0

__Notes:__
I also discovered that installing them all inline as:

npm i -g @angular-devkit/core @angular-devkit/schematics @schematics/angular @nrwl/schematics @angular/cli

results in:
~$ npm -g ls --depth=0 ~/.nvm/versions/node/v8.9.1/lib ├── @angular/[email protected] ├── @nrwl/[email protected] └── [email protected]
which will still result in the same errors. Which is why I suggest just uninstalling them all and then reinstalling one-by-one in that order.

All 7 comments

Same problem here. Running:

  • Node 8.9.4
  • Yarn 1.3.2
  • Windows 8.1

Same problem here as well:

  • Node 8.9.3
  • NPM 5.6.0
  • Angular CLI 1.6.5 (<= I think this is the problem)
  • Windows 10

Same problem here

  • Node 8.4.0
  • Yarn 1.3.2
  • Angular CLI 1.6.3
  • Fedora 27

I had the same issue, seems to be related to stuff discussed here https://github.com/angular/angular-cli/issues/9194.

I found the following workaround, though:

npm un -g @angular-devkit/core @angular-devkit/schematics @schematics/angular @nrwl/schematics @angular/cli
npm i -g @angular-devkit/core
npm i -g @angular-devkit/schematics
npm i -g @schematics/angular
npm i -g @nrwl/schematics
npm i -g @angular/cli

Once finished your global tree should look something like this:

~$ npm -g ls --depth=0
~/.nvm/versions/node/v8.9.1/lib
├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @nrwl/[email protected]
├── @schematics/[email protected]
└── [email protected]

After that I ran:

ng new "PROJECT_NAME" --collection=@nrwl/schematics # same as what create-nx-workspace does, but I still had issues when running create-nx-workspace

And the project was successfully created.

You will then need to cd into the created project and run:

npm i -D @angular-devkit/core

To be able to generate apps, libs, components, etc.

__Environment:__

  • Mac OS X Sierra 10.12.6 (16G1036)
  • Node 8.9.1
  • NPM 5.6.0

__Notes:__
I also discovered that installing them all inline as:

npm i -g @angular-devkit/core @angular-devkit/schematics @schematics/angular @nrwl/schematics @angular/cli

results in:
~$ npm -g ls --depth=0 ~/.nvm/versions/node/v8.9.1/lib ├── @angular/[email protected] ├── @nrwl/[email protected] └── [email protected]
which will still result in the same errors. Which is why I suggest just uninstalling them all and then reinstalling one-by-one in that order.

I was successfully able to generate a new project with the workaround. Thank you! :)

NOTE: I had to add the following to the .angular-cli.json to generate the first app:

"apps": [
{
"name": "dummy",
"root": "./src",
"test": "../../../test.js",
"appRoot": ""
}
],

When I created the first library after that, to get the source path to be generated correctly I had to keep the above entry as the first one in the "apps" array

The CLI removed the dependency on @angular-devkit/core. I released a new version of Nx fixing it.

Right now the only package you need to to be able to run create-nx-workspace is @nrwl/schematics. You don't need to install anything else globally.

Closing this issue.

ng new workspace --col @nrwl/schematics

Was this page helpful?
0 / 5 - 0 ratings