【问题标题】:Angular Generate component through path already exists errorAngular Generate component through path has already exists错误
【发布时间】:2018-10-06 14:51:38
【问题描述】:

我正在尝试运行简单的组件生成命令,该命令会引发如下错误:

命令:

sudo ng generate component forgot-pass

错误信息:

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

我对这个错误一无所知,我的应用程序正在正确构建,并且在检查时没有这样的单个文件夹或文件。

如果我放任何东西而不是忘记密码,它会抛出同样的错误。

仅供参考,这是我的 cli 使用的版本:

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


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

【问题讨论】:

  • 什么是 Angular cli 版本
  • 编辑问题

标签: angular angular-cli-v6


【解决方案1】:

由于某些文件被创建了两次,这似乎是该版本的 angular cli 的一个已知问题。可能你能做的就是创建一个新的应用程序。

您可以通过更新 Angular cli 版本来解决此问题sudo npm update @angular/cli latest

【讨论】:

  • 我的项目有点大,我不能用新项目做,我可以更新 angular CLI 吗?
  • 请编辑答案作为替代。我做了 sudo npm update @angular/cli latest 这对我有用
  • 这就是我在答案中已经提到的。反正我会更新
猜你喜欢
  • 1970-01-01
  • 2023-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-09
  • 2017-04-05
  • 2018-09-21
相关资源
最近更新 更多