使用 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/