Angular 角度4生成元件误差
我是新来的。我正在尝试使用angular CLI创建新组件Angular 角度4生成元件误差,angular,Angular,我是新来的。我正在尝试使用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. 它可能来自您的安装/版本。尝试卸载/重新安装它: 一般重新安装 npm uninstall -g @angular/cli np
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.
它可能来自您的
安装/版本。尝试卸载/重新安装它:
一般重新安装
npm uninstall -g @angular/cli
npm install -g @angular/cli
为本地项目重新安装:
npm uninstall --save @angular/cli
npm install --save @angular/cli
删除node_modules文件夹并转到要在其中生成新组件的路径(myFolder),然后运行以下命令
ng g component my-new-component
使用cd myFolder转到myFolder文件夹
之后,使用此注释生成组件newcomment
使用也可以像这样使用ng g c NewcomComponent
您确定myFolder
是您项目中的一个模块吗?如果它只是一个普通文件夹,我建议手动使用cd
在文件夹中导航,然后执行以下操作
ng g c您的组件名称
当您输入
ng g c folder name/您的组件名称时,angular希望文件夹名称实际上是一个由.module.ts文件组成的模块。否。它不起作用。我得到了这个错误,编译失败/node_modules/process/browser.js模块构建失败:错误:enoint:没有这样的文件或目录,打开'C:\Users\user\angular2\my_proj\proj1\node_modules\process\browser.js'@./node_modules/zone.js/dist/zone.js 1:0-37@./src/polyfills.ts@multi./src/polyfills.ts尝试重新安装后出现此错误?看看这篇文章,这似乎是你的错误:我不认为。这将是一个解决方案。我的错误是在不同的情况下发生的。不,从我这边开始。您的解决方案可能对其他编码器有用。我正在手动创建组件。您使用哪个angular cli版本?运行此命令时收到的错误消息是什么?尝试删除节点模块文件夹并运行此命令。我收到相同的错误消息“error:tree.branch不是函数树。branch不是函数”。请参阅此处,此问题将出现在最新版本中。训练是在同一链接中给出的。你能分享一些代码吗,或者在回购协议中分享。对不起。不可能再耽搁了。它按我想要的方式工作。