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-
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/build-angular@0.6.8
│ └── webpack@4.8.3
└── webpack@4.17.1
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.
I encountered this problem when trying to add lazy load feature in Angular 8.
├─┬ @angular-devkit/build-angular@0.803.29
| └── webpack@4.39.2
└── webpack@4.41.1
I tried to update @angular-devkit/build-angular to latest but was not working. Many new issues surfaced. When I removed webpack@4.41.1, the same problem 'cannot find module webpack'. So I tried to make the webpack versions same. Used 'npm install webpack@4.39.2'. Finally the problem was solved. When I type 'npm ls webpack', only one webpack is shown and the build works fine.
`-- @angular-devkit/build-angular@0.803.29
`-- webpack@4.39.2
If removing webpack from your package.json doesn't work for you:
In my case I just needed to update the following dependencies : "@angular-devkit/core", "@angular-devkit/build-angular", and "@angular-devkit/schematics" to the following version : "0.8.1".
This way "@angular-devkit/build-angular" had the same version than the webpack specified in my package.json (4.18.0).
This means that if your run npm ls webpack
and have multiple results, you don't have to remove webpack from your project, you just need both versions to be the same.
This error occurred because then compatible webpack version is higher then @angular-devkit/build-angular solution:- npm update @angular-devkit/build-angular --save-dev
let me know if it works