Nx: Cannot find module '@schematics/angular/strings' error when trying to create a new workspace

Created on 6 Nov 2017  路  7Comments  路  Source: nrwl/nx

It doesn't matter if I use the script or a globally installed @angular/cli I just keep getting this error:

Binary is fine
added 969 packages in 33.703s
Creating a new project...
Cannot find module '@angular-devkit/schematics'
Error: Cannot find module '@angular-devkit/schematics'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@nrwl/schematics/src/application/index.js:11:20)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)

Naturally I tried to install @angular-devkit/schematics but then the error changed to this one:

Cannot find module '@schematics/angular/strings'
Error: Cannot find module '@schematics/angular/strings'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@nrwl/schematics/src/application/index.js:12:19)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)

I'm not familiar enough with schematics and @schematics/angular/strings isn't a module (or, at least, I can't install it through yarn/npm. What's happening here?
I tried both the current and next scripts, and installing nx globally and everything is failing.

Most helpful comment

Docs have been updated to explain the need for yarn for generating new workspaces only. Thx again for the feedback!

All 7 comments

Having same issue, only on Windows 10 PC. Everything works fine on MacOS

That's weird, I'm getting these errors on my Mac

I can confirm this error. Happens for me on both: Windows 10 and MacOS.
@vsavkin can you please give us a hint how to solve this?

Hey guys, I tried removing the @angular/cli and re-installing it using yarn and it seems to fix the issue. Maybe just change the statement here:
Yarn does a better job at recognizing and dealing with multiple peer dependencies on globally installed packages, thus is recommended (but not a hard requirement) to reflect that yarn is a hard requirement?

@rmacteague @domkrel did you try what @alterx did? Have any luck getting it to work?

Yarn is a hard requirement for new workspace creation when using ng new to create a new Nx Workspace, but the rest of the Nx schematics can be used with npm...thus why we went with the "not a hard requirement". But that being said, we will update the docs to explain this scenario more clearly.

I can confirm that yarn fixed the problem.

Docs have been updated to explain the need for yarn for generating new workspaces only. Thx again for the feedback!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joelmuskwe picture joelmuskwe  路  3Comments

ZempTime picture ZempTime  路  3Comments

markphip picture markphip  路  3Comments

olakara picture olakara  路  3Comments

MichaelWarneke picture MichaelWarneke  路  3Comments