Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - TypeError: Cannot read property 'write' of undefined

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? .

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.

like image 691
DTek Avatar asked Jul 26 '18 13:07

DTek


3 Answers

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

Update:

As per prionp answer below:

Angular CLI v6.1.2 fixed the issue.

Update your version :

npm update -g @angular/cli
like image 71
Damián Pereira Avatar answered Nov 20 '22 12:11

Damián Pereira


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

npm uninstall -g @angular/cli
npm install -g @angular/[email protected]
like image 24
Abhilash L Avatar answered Nov 20 '22 12:11

Abhilash L


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:

npm uninstall -g @angular/cli 
npm install -g @angular/[email protected]
like image 5
Ehsan Avatar answered Nov 20 '22 13:11

Ehsan