Angular 7 CLI ng生成组件错误:“无法读取未定义的属性” sourceRoot”

时间:2018-11-28 19:55:33

标签: angular components command-line-interface angular7 generate

当我尝试在CLI上运行以下命令时,我收到以下错误:

ng generate component [component-name]

我不断得到:

Cannot read property 'sourceRoot' of undefined

我想我是在更新我使用的angular版本之后才开始得到它的。 Cannot read property 'sourceRoot' of undefined

请参阅回复以获取解决方案。

1 个答案:

答案 0 :(得分:0)

要解决此问题,我必须转到Angular.json文件夹。

  1. 搜索“ e2e”
  2. 将“ root”从“ e2e /”更新为“ /”。 该位置在“ [项目名称] -e2e”下

enter image description here

更新后,我便可以运行命令

ng generate component [component-name]

没有问题

ng generate component product-search