简体   繁体   English

Angular-Cli'ng g c my-new-component'错误:无法找到(未定义)且无法找到(未定义)

[英]Angular-Cli 'ng g c my-new-component' Error: Could not find (undefined) and Could not find (undefined)

Problem: 问题:

In my angular 5+ app project, in one of my subfolder, after I typed ng gc my-component commend, Nothing generated ,instead, it popup some unknown errors, anyone know what is going on here? 在我的angular 5+应用程序项目中,在我的一个子文件夹中,在输入ng gc my-component ,没有生成,而是弹出一些未知错误,任何人都知道这里发生了什么? I've reinstalled the npm/angular@cli for many times. 我已经多次重新安装了npm / angular @ cli。

jocs@Jocs ~/r/s/a/pages (devReno)> ng g c my-new-component
Error: Could not find (undefined)
Could not find (undefined)
jocs@Jocs ~/r/s/a/pages (devReno) [1]> ng generate component my-new-component
Error: Could not find (undefined)
Could not find (undefined)
jocs@Jocs ~/r/s/a/pages (devReno) [1]>

终端屏幕截图(图像链接)
Dev Environments: 开发环境:

OS: darwin x64(Mac OS: 10.13.4) 操作系统:darwin x64(Mac OS:10.13.4)

Angular CLI: 1.7.4 Angular CLI:1.7.4

Node: 9.11.1 节点:9.11.1

Angular: 5.2.9 Angular:5.2.9

I had that problem and I had to reinstall Angular Cli. 我有这个问题,我不得不重新安装Angular Cli。

The way I reinstalled is by downgrading and then upgrading it back. 我重新安装的方式是降级然后再升级。 I supposed you can also remove either the package from node_modules or doing npm uninstall @angular/cli and then npm i @angular/cli@1.7.4 . 我想你也可以从node_modules删除包或者执行npm uninstall @angular/cli然后npm i @angular/cli@1.7.4

The way that worked for me was doing this: 对我有用的方法是这样做:

My version of npm (version 6.0) will downgrade angular cli if I install a different version $ npm i @angular/cli@1.7.3 如果我安装了不同的版本$ npm i @angular/cli@1.7.3我的npm版本(版本6.0)将降级角度cli

Then I upgraded back to 1.7.4 $ npm i @angular/cli@1.7.4 然后我升级回1.7.4 $ npm i @angular/cli@1.7.4

The issue in my case was that I had files and nodes directories in the root directory. 我的问题是我在根目录中有文件和节点目录。 I remove it. 我删除它。

rm -rf node_modules/
rm package-lock.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM