Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callback was already called angular cli

I updated my angular-cli then i got error in ng serve

 Callback was already called.
at throwError (node_modules\neo-async\async.js:14:11)
at node_modules\neo-async\async.js:2805:7
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

and this is versions of my project packages:

Angular CLI: 6.0.7
Node: 8.9.4
OS: win32 x64
Angular: 5.0.1

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.7
@angular-devkit/build-angular     0.6.7
@angular-devkit/build-optimizer   0.6.7
@angular-devkit/core              0.6.7
@angular-devkit/schematics        0.6.7
@angular/cdk                      5.2.4
@angular/cli                      6.0.7
@angular/material                 5.2.4
@angular/platform-server          5.1.1
@ngtools/webpack                  6.0.7
@schematics/angular               0.6.7
@schematics/update                0.6.7
rxjs                              5.5.2
typescript                        2.4.2
webpack                           4.4.1

I tried to remove node-modules then re- npm install but still have the same error ... any suggestions ?

like image 322
Aya Abdelaziz Avatar asked May 30 '18 08:05

Aya Abdelaziz


1 Answers

I had a similar problem and found a solution thanks to this discussion:

https://github.com/angular/angular-cli/issues/6417

It seems to be a problem triggered when updating to Angular 6.

First run:

sudo npm ls webpack

If it returns more than one version of webpack, that's where your problem lies:

├─┬ @angular-devkit/[email protected]
│ └── [email protected] 
└── [email protected] 

Unless you have need for it elsewhere, you only need webpack to be in @angular-devkit/build-angular.

I'd also updated all of @angular-devkit/* with @latest.

Once it was clear there was more than one version, I did the following to get it working again:

sudo npm uninstall --save-dev webpack
sudo npm ls webpack
sudo npm cache verify

I had uninstalled @angular-devkit/build-angular in trying to find the solution. So I plugged that back in before doing anything else. It seems to have its own version of webpack with it. If you already have it there, just update it.

Note that I didn't reinstall webpack with sudo npm i webpack. It didn't like that no matter what way I tried it.

sudo npm install @angular-devkit/build-angular@latest
sudo npm ls webpack

Once there was only one version of webpack, ng serve should work again with no errors.

P.S. An alternative fix suggested by peterpeterparker helped me find this solution. Please note that I haven't tried it, but thought it may be helpful.

peterpeterparker's fix:

 npm remove webpack --save
 rm -r node_modules
 rm package-lock.json
 npm install

P.P.S. Sudo is only for mac. I added it for ease of copy & paste of my solution. Don't copy it if you don't need it.

like image 66
ImaRoxtaar Avatar answered Oct 10 '22 15:10

ImaRoxtaar