Callback was already called angular cli

前端 未结 4 492
予麋鹿
予麋鹿 2021-02-04 11:30

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-         


        
4条回答
  •  醉梦人生
    2021-02-04 12:01

    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.

提交回复
热议问题