Angular - TypeError:无法读取undefined的属性'write'

时间:2022-08-24 13:21:22

I'm working on a club project and we are using angular for our platform, I'm just doing front-end homepage stuff, so technically I just use the angular stuff to run and test.

我正在研究一个俱乐部项目,我们正在为我们的平台使用角度,我只是做前端主页的东西,所以从技术上讲,我只是使用角度来运行和测试。

It was working fine but now everytime I run ng build --watch I get this error:

它工作正常,但现在每次我运行构建 - 手表我得到这个错误:

C:\Users\User\Documents\WebstormProjects\MyProject\angular-src\node_modules\@angular\cli\ember-cli\lib\ui\index.js:56
    this.outputStream.write(data);
                      ^

TypeError: Cannot read property 'write' of undefined
    at UI.write (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\@angular\cli\ember-cli\lib\ui\index.js:56:23)
    at UI.writeLine (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\@angular\cli\ember-cli\lib\ui\index.js:69:8)
    at Watching.callback [as handler] (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\@angular\cli\tasks\build.js:44:29)
    at Watching._done (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:106:8)
    at compiler.emitRecords.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:79:19)
    at Compiler.emitRecords (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:371:38)
    at compiler.emitAssets.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:62:20)
    at applyPluginsAsyncSeries1.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:364:12)
    at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:218:11)
    at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
    at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
    at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\@ngtools\webpack\src\plugin.js:326:13)
    at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
    at callback (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:126:17)
    at Compiler.afterEmit (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:220:13)
    at Compiler.applyPluginsAsyncSeries1 (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:222:13)

I'm totally lost around this, I've tried multiple threads to reinstall node and angular and nothing. I've followed this one in particular: How to uninstall Angular CLI? .

我完全迷失了这个,我尝试了多个线程重新安装节点和角度,没有。我特别关注了这个:如何卸载Angular CLI? 。

The weirdest part is now when I try to do this on ubuntu by cloning the project, setting the env variables and do npm install, every time I do ng watch build it gives me the same error. But apparently, I'm the only one on the team.

最奇怪的部分是现在,当我尝试通过克隆项目,设置env变量并执行npm install在ubuntu上执行此操作时,每次执行watch build时它都会给出同样的错误。但显然,我是团队中唯一的一员。

5 个解决方案

#1


11  

It's because of the new Angular version. Go with the old Angular version:

这是因为新的Angular版本。使用旧的Angular版本:

npm uninstall -g @angular/cli
npm install -g @angular/cli@6.0.8

#2


4  

Seems to be caused by latest version of Angular CLI (released today). I worked around it by installing previous version (6.0.8) globally.

似乎是由最新版本的Angular CLI(今天发布)引起的。我通过在全球范围内安装以前的版本(6.0.8)来解决这个问题。

#3


3  

I have tried to install angular(version 6.1.1 and 6.1.0 and 6.0.9). unfortunately, I have faced error in all of mentioned versions. But, I could install angular 6.0.8 successfully. try this command in your console:

我试图安装angular(版本6.1.1和6.1.0和6.0.9)。不幸的是,我在所有提到的版本中都遇到了错误。但是,我可以成功安装角度6.0.8。在您的控制台中尝试此命令:

npm uninstall -g @angular/cli 
npm install -g @angular/cli@6.0.8

#4


1  

Angular CLI v6.1.2 fixed the issue.

Angular CLI v6.1.2修复了该问题。

Update your version :

更新您的版本:

npm update -g @angular/cli

#5


0  

Faced the same issue, its related to both 6.10 and 6.11, one option is to downgrade your @angular/cli to 6.0.8 or to update the local @angular/cli manually

面对同样的问题,它与6.10和6.11相关,一个选项是将@ angular / cli降级到6.0.8或手动更新本地@ angular / cli

#1


11  

It's because of the new Angular version. Go with the old Angular version:

这是因为新的Angular版本。使用旧的Angular版本:

npm uninstall -g @angular/cli
npm install -g @angular/cli@6.0.8

#2


4  

Seems to be caused by latest version of Angular CLI (released today). I worked around it by installing previous version (6.0.8) globally.

似乎是由最新版本的Angular CLI(今天发布)引起的。我通过在全球范围内安装以前的版本(6.0.8)来解决这个问题。

#3


3  

I have tried to install angular(version 6.1.1 and 6.1.0 and 6.0.9). unfortunately, I have faced error in all of mentioned versions. But, I could install angular 6.0.8 successfully. try this command in your console:

我试图安装angular(版本6.1.1和6.1.0和6.0.9)。不幸的是,我在所有提到的版本中都遇到了错误。但是,我可以成功安装角度6.0.8。在您的控制台中尝试此命令:

npm uninstall -g @angular/cli 
npm install -g @angular/cli@6.0.8

#4


1  

Angular CLI v6.1.2 fixed the issue.

Angular CLI v6.1.2修复了该问题。

Update your version :

更新您的版本:

npm update -g @angular/cli

#5


0  

Faced the same issue, its related to both 6.10 and 6.11, one option is to downgrade your @angular/cli to 6.0.8 or to update the local @angular/cli manually

面对同样的问题,它与6.10和6.11相关,一个选项是将@ angular / cli降级到6.0.8或手动更新本地@ angular / cli