Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng new does not resolve dependencies of specified collection #11026

Closed
FrozenPandaz opened this issue May 25, 2018 · 5 comments
Closed

ng new does not resolve dependencies of specified collection #11026

FrozenPandaz opened this issue May 25, 2018 · 5 comments
Labels
area: @angular-devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@FrozenPandaz
Copy link
Contributor

FrozenPandaz commented May 25, 2018

Versions

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 6.0.5
Node: 8.11.1
OS: linux x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.5
@angular-devkit/core         0.6.5
@angular-devkit/schematics   0.6.5
@schematics/angular          0.6.5
@schematics/update           0.6.5
rxjs                         6.2.0
typescript                   2.7.2

Repro steps

npm i @nrwl/schematics -g
ng new workspace --collection @nrwl/schematics

Observed behavior

Throws an error

Could not find module "@ngrx/schematics" from "/home/jason/projects/work/temp/temp".
Error: Could not find module "@ngrx/schematics" from "/home/jason/projects/work/temp/temp".
    at Object.resolve (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/node/resolve.js:141:11)
    at NodeModulesEngineHost._resolvePackageJson (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:29:21)
    at NodeModulesEngineHost._resolveCollectionPath (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:70:40)
    at NodeModulesEngineHost.createCollectionDescription (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:106:27)
    at SchematicEngine._createCollectionDescription (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:78:40)
    at SchematicEngine._createCollectionDescription (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:89:48)
    at SchematicEngine.createCollection (/usr/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:71:43)
    at Object.getCollection (/usr/lib/node_modules/@angular/cli/utilities/schematics.js:28:31)
    at NewCommand.getOptions (/usr/lib/node_modules/@angular/cli/models/schematic-command.js:193:41)
    at NewCommand.initialize (/usr/lib/node_modules/@angular/cli/commands/new.js:48:21)

Desired behavior

We have a dependency on @ngrx/schematics. ng new should be able to resolve it from globalNodeModules/@nrwl/schematics/node_modules/@ngrx/schematics

jason@Jason-PC-U:~/projects/work/temp/nx6workspace$ npm ls @ngrx/schematics -g
/usr/lib
└─┬ @nrwl/[email protected]
  └── @ngrx/[email protected] 

Mention any other details that might be useful (optional)

Workaround

The workaround for users is to also manually install the dependency globally

@meixuexiang
Copy link

+1

$ npm list --depth 0 -g
/usr/local/lib
├── @angular/[email protected]
├── @nrwl/[email protected]
└── [email protected]

$ ng new myworkspacename --collection=@nrwl/schematics
Could not find module "@ngrx/schematics" from "/Volumes/repo/test".
Error: Could not find module "@ngrx/schematics" from "/Volumes/repo/test".
at Object.resolve (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/node/resolve.js:141:11)
at NodeModulesEngineHost._resolvePackageJson (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:28:21)
at NodeModulesEngineHost._resolveCollectionPath (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:69:40)
at NodeModulesEngineHost.createCollectionDescription (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:106:27)
at SchematicEngine._createCollectionDescription (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:78:40)
at SchematicEngine._createCollectionDescription (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:89:48)
at SchematicEngine.createCollection (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:71:43)
at Object.getCollection (/usr/local/lib/node_modules/@angular/cli/utilities/schematics.js:28:31)
at NewCommand.getOptions (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:193:41)
at NewCommand.initialize (/usr/local/lib/node_modules/@angular/cli/commands/new.js:48:21)

@hansl hansl added freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: @angular-devkit/schematics and removed comp: cli/new labels Jun 7, 2018
@hansl
Copy link
Contributor

hansl commented Jun 7, 2018

@FrozenPandaz This looks like an issue with the node resolver we use for resolving packages.

@meixuexiang this will never work, but the error message should be "cannot use an empty collection name" or similar.

@FrozenPandaz
Copy link
Contributor Author

FrozenPandaz commented Jun 15, 2018

Thanks for taking a look @hansl.

That's unfortunate... Is there an open issue or should we make one? I dug through and could not seem to find the resolution code so I'm not sure which dependency it is.

Is there a workaround in the meantime? (One that the devkit can use to workaround the issue of the dependency I mean)

@markgoho
Copy link
Contributor

Any update on this?

@ngbot ngbot bot added this to the Backlog milestone Jan 24, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Sep 17, 2020
…uesting collection

This change first attempts to resolve a schematic referenced via the external schematic rule from the requesting schematic collection.  This allows schematic packages that are direct dependencies of another schematic package to be used with the external schematic rule without manual package resolution code within the schematic.

Closes angular#18098
Closes angular#11026
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

5 participants