nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.28k stars 2.32k forks source link

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

Closed alterx closed 6 years ago

alterx commented 6 years ago

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.

rmacteague commented 6 years ago

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

alterx commented 6 years ago

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

domkrel commented 6 years ago

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?

alterx commented 6 years ago

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?

jschwarty commented 6 years ago

@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.

domkrel commented 6 years ago

I can confirm that yarn fixed the problem.

jschwarty commented 6 years ago

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

github-actions[bot] commented 1 year ago

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.