angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

materialNav schematics/collision in latest version

Open jayChrono opened this issue 8 years ago • 20 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.0.8 Node: 8.11.3 OS: win32 x64 Angular: 6.0.9 ... common, compiler, compiler-cli, core, forms, http ... language-service, platform-browser, platform-browser-dynamic ... router

Package Version

@angular-devkit/architect 0.6.8 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.6.8 @angular-devkit/schematics 0.6.8 @angular/cli 6.0.8 @angular/material 6.4.1 @ngtools/webpack 6.0.8 @schematics/angular 0.6.8 @schematics/update 0.6.8 rxjs 6.2.2 typescript 2.7.2 webpack 4.8.3

Repro steps

ng new my-app npm install @angular/material @angular/cdk --save npm install @angular/animations ng generate @angular/material:material-nav --name test-nav

The log given by the failure

Schematics/alias "materialNav" collides with another alias or schematic name. Error: Schematics/alias "materialNav" collides with another alias or schematic name. at NodeModulesEngineHost.createCollectionDescription (C:\Users\Jay\git\my-resume\node_modules@angular-devkit\schematics\tools\file-system-engine-host-base.js:125:27) at SchematicEngine._createCollectionDescription (C:\Users\Jay\git\my-resume\node_modules@angular-devkit\schematics\src\engine\engine.js:78:40) at SchematicEngine.createCollection (C:\Users\Jay\git\my-resume\node_modules@angular-devkit\schematics\src\engine\engine.js:71:43) at Object.getCollection (C:\Users\Jay\git\my-resume\node_modules@angular\cli\utilities\schematics.js:28:31) at GenerateCommand.getOptions (C:\Users\Jay\git\my-resume\node_modules@angular\cli\models\schematic-command.js:193:41) at GenerateCommand. (C:\Users\Jay\git\my-resume\node_modules@angular\cli\commands\generate.js:38:53) at Generator.next () at C:\Users\Jay\git\my-resume\node_modules@angular\cli\commands\generate.js:7:71 at new Promise () at __awaiter (C:\Users\Jay\git\my-resume\node_modules@angular\cli\commands\generate.js:3:12)

Desired functionality

It should generate the component from the schematic without error.

Mention any other details that might be useful

I've traced it to line 127 in @angular-devkit/schematics/tools/file-system-host-base.js. The code 'allNames.push(...aliases);' appears to push the array ['material-nav', 'materialNav'] into allNames. Since it's in a for loop, the array gets pushed twice. I manually edited the line to 'allNames.push(alias);' and it generated the component as desired.

jayChrono avatar Jul 24 '18 01:07 jayChrono

Thanks for putting your fix in there, this was driving me crazy.

joshstir avatar Jul 24 '18 01:07 joshstir

I just had the same problem but sadly the suggested solution didn't work for me. Instead I moved the line 127: allNames.push(...aliases); outside, just after, the loop so it's now on line 128. Now everything works fine for me.

tomasvaedelund avatar Jul 24 '18 07:07 tomasvaedelund

Worked for me thanks :)

kartikwatwani avatar Jul 24 '18 07:07 kartikwatwani

in sources https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts line allNames.push(...aliases); already moved out of that cycle.

IAfanasov avatar Jul 24 '18 08:07 IAfanasov

is there any workaround for this issue ?

thesayyn avatar Jul 24 '18 08:07 thesayyn

@thesayyn two workarounds have been already listed in this topic. read above

IAfanasov avatar Jul 24 '18 08:07 IAfanasov

I moved the line as suggested by @tomasvaedelund and it worked fine for me.

LAMASLAYER avatar Jul 24 '18 09:07 LAMASLAYER

I believe this was fixed by https://github.com/angular/angular-cli/pull/11390, and the latest 6.1 RC should not have this problem. Please let me know if that's not the case so I can reopen.

filipesilva avatar Jul 24 '18 09:07 filipesilva

got it fixed. thank you @jayChrono

HARINI-VARADHARAJAN avatar Jul 24 '18 17:07 HARINI-VARADHARAJAN

thanks

AnshulMahajan10 avatar Jul 24 '18 19:07 AnshulMahajan10

thanks bro, @jayChrono

GuanYuMin avatar Jul 24 '18 19:07 GuanYuMin

Thanks it worked for me. @jayChrono

codefordream2014 avatar Jul 25 '18 05:07 codefordream2014

thnx @jayChrono i changed allNames.push(...aliases); to allNames.push(alias); at line 127 . and it worked fine

itsd2112 avatar Jul 25 '18 15:07 itsd2112

Thanks all, what @tomasvaedelund said work fine for me.

eudys07 avatar Jul 25 '18 16:07 eudys07

allNames.push(...aliases); to allNames.push(alias); at line 127, after making this change, this issue got fixed but another issue started when I run command generate component , its giving error, schematics/alias "c" collides with another alias or schematic name,** I had to undo the code change and this issue went away

image

AnshulMahajan10 avatar Jul 25 '18 16:07 AnshulMahajan10

Changing allNames.push(...aliases); to allNames.push(aliases) worked for me.

JoshWilliams92 avatar Jul 26 '18 12:07 JoshWilliams92

Angular CLI 6.1 has a fix for it.. try running ng update @angular/cli

gags88 avatar Jul 30 '18 02:07 gags88

I changed the line 127 just like @jayChrono said and it worked. Thanks man!!

diemgomez avatar Nov 04 '18 00:11 diemgomez

what is line 127 please ?

slim-souissi avatar Nov 27 '18 13:11 slim-souissi

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.