回调已称为angular cli [英] Callback was already called angular cli
问题描述
我更新了我的angular-cli,然后在ng服务中出现错误
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
除非您在其他地方需要它,否则只需要将webpack放在@ angular-devkit/build-angular中即可.
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.
P.S. 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.
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屋!