Reputation: 528
I am new in angular 4. I am trying to create new Component using 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.
Upvotes: 3
Views: 3898
Reputation: 528
now we can do one thing, go to folder using cd myFolder.
C:\project\myFolder> ng g c newComponent --flat
Upvotes: 0
Reputation: 111
Are you sure myFolder
is a module in your project? If it is just a normal folder, I would recommend navigating inside the folder with cd
manually and then doing the following
ng g c your-component-name
.
When you enter ng g c folder-name/your-component-name
, angular expects folder-name to actually be a module which consists of .module.ts file.
Upvotes: 0
Reputation: 26
Go to myFolder folder using >cd myFolder
After that use this comment >ng generate component newComponent
Use can use like this also >ng g c newComponent
Upvotes: 1
Reputation: 4207
It probably comes from your angular-cli
installation/version. Try to uninstall/re-install it :
Re-install generally
npm uninstall -g @angular/cli
npm install -g @angular/cli
Re-install for a local project :
npm uninstall --save @angular/cli
npm install --save @angular/cli
Upvotes: 2
Reputation: 2736
Delete the node_modules folder and go to the path (myFolder) where you want to generate a new component and run the below command
ng g component my-new-component
Upvotes: 0