angularjs - Angular 2 : Error while creating new component via CLI

标签 angularjs macos angular terminal command-line-interface

使用 Angular2,移入项目文件夹后,我在尝试通过 CLI 创建新组件时遇到此错误,我将发布所有终端消息:

edoardocanti$ ng generate component other
Could not start watchman; falling back to NodeWatcher for file system          
events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
installing component
create src/app/other/other.component.css
create src/app/other/other.component.html
create src/app/other/other.component.spec.ts
create src/app/other/other.component.ts
Cannot read property 'read' of undefined
TypeError: Cannot read property 'read' of undefined
at InsertChange.apply (/Users/edoardocanti/first-     
app/node_modules/@angular-cli/ast-tools/src/change.js:96:20)
at /Users/edoardocanti/first-app/node_modules/@angular-cli/ast-  
tools/src/change.js:71:61
at process._tickCallback (internal/process/next_tick.js:103:7) 

它创建了我的新组件的文件夹,但我必须在 app.module.ts 中手动添加它,但它可以工作。

真正的问题是当我尝试在现有文件夹中创建新组件时,在这种情况下 Angular 不会创建任何新组件。

最佳答案

你使用的是 angular-cli 1.0.0.beta15 吗?如果是这样,npm install -g angular-cli@latest。这个问题似乎在 beta16 中就消失了

关于angularjs - Angular 2 : Error while creating new component via CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39777519/

相关文章:

javascript - 根据ng-repeat中的条件动态选择angularjs过滤器

javascript - 尝试上传图像并使其显示在屏幕上

java - 玩!框架运行抛出 UnsupportedClassVersionError

swift - 在屏幕解锁上激活应用程序

objective-c - 无法在 OSX 上从 64 位进程加载 32 位 dylib,反之亦然?

Angular :错误 NG8001: 'mat-select' 不是已知元素:

javascript - 带有 Twitter Bootstrap 的 JSON 的 AngularJS 菜单和子菜单

javascript - 在 AngularJS 中准备好文档

node.js - Npm链接在Angular7项目中不起作用

javascript - 使用rxjs实现指数补偿