Angular通过路径生成组件已存在错误 [英] Angular Generate component through path already exists error

查看:187
本文介绍了Angular通过路径生成组件已存在错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

命令:

sudo ng generate component forgot-pass

错误消息:

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.

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

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


推荐答案

由于某些文件被创建了两次,因此该版本的cli似乎是一个已知问题。

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.

您可以通过更新角度cli版本 sudo npm update @来解决此问题。 angular / cli最新

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

这篇关于Angular通过路径生成组件已存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆