我是angular 4的初学者。我正在尝试使用angular CLI创建新组件。
command : ng generate component myFolder/newComponent
But I am getting below error:
Error: tree.branch is not a function
tree.branch is not a function.
我是angular 4的初学者。我正在尝试使用angular CLI创建新组件。
command : ng generate component myFolder/newComponent
But I am getting below error:
Error: tree.branch is not a function
tree.branch is not a function.
这可能与您的angular-cli
安装/版本有关。尝试卸载/重新安装它:
通常情况下,重新安装即可解决问题。
npm uninstall -g @angular/cli
npm install -g @angular/cli
重新安装本地项目:
npm uninstall --save @angular/cli
npm install --save @angular/cli
node_modules
文件夹并重新安装依赖项。 - Boulboulouboule使用>cd myFolder
命令转到myFolder文件夹。
然后使用>ng generate component newComponent
命令。
也可以使用>ng g c newComponent
命令。
你确定 myFolder
是你项目中的一个模块吗?如果它只是一个普通的文件夹,我建议手动使用 cd
进入该文件夹,然后执行以下操作:
ng g c your-component-name
。
当你输入 ng g c folder-name/your-component-name
时,Angular 期望 folder-name 实际上是一个包含 .module.ts 文件的模块。
现在我们可以做一件事情,使用 cd myFolder 命令进入文件夹。
C:\project\myFolder> ng g c newComponent --flat
ng g component my-new-component