回调已经被称为 angular cli [英] Callback was already called angular cli

查看:22
本文介绍了回调已经被称为 angular cli的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了我的 angular-cli 然后我在 ng serve 中出错

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

我尝试删除节点模块然后重新安装 npm 但仍然有相同的错误......有什么建议吗?

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

推荐答案

我遇到了类似的问题,并通过这次讨论找到了解决方案:

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

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

似乎是更新到 Angular 6 时触发的问题.

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

第一次运行:

sudo npm ls webpack

如果它返回多个版本的 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 

除非你在其他地方需要它,否则你只需要在@angular-devkit/build-angular 中使用 webpack.

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

我还用@latest 更新了所有@angular-devkit/*.

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

为了找到解决方案,我卸载了@angular-devkit/build-angular.所以我在做任何其他事情之前把它插回去.它似乎有自己的 webpack 版本.如果您已经拥有它,只需更新它.

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.

请注意,我没有使用 sudo npm i webpack 重新安装 webpack.不管我怎么尝试,它都不喜欢那样.

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

一旦只有一个版本的 webpack,ng serve 应该可以再次正常工作,没有错误.

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

附言peterpeterparker 建议的替代解决方案帮助我找到了这个解决方案.请注意,我还没有尝试过,但认为它可能会有所帮助.

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 的修复:

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

P.P.S.Sudo 仅适用于 mac.我添加它是为了便于复制 &粘贴我的解决方案.不需要就不要复制.

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.

这篇关于回调已经被称为 angular cli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆