Search code examples
angularangular-cli-v6

Angular Generate component through path already exists error


I am trying to run simple component generate command which is throwing error like this:

command:

sudo ng generate component forgot-pass

Error Msg:

Path "/src/app/forgot-pass/forgot-pass.component.css" already exist.

I am clueless about this error, my application is building properly and when check there is not a single folder or file like this.

If I put anything istead of forgot-pass, it throws the same error.

FYI, here is the version my cli is using:

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


Angular CLI: 6.0.1
Node: 8.11.2
OS: darwin x64
Angular: 6.0.2
... common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@angular/animations               6.1.2
@angular/cli                      6.0.1
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.6.0

Solution

  • This seems to be a known issue with that version of angular cli due to some files were created twice. probably what you can do is to create a new app.

    You can resolve this by updating your angular cli version sudo npm update @angular/cli latest