升级到angular 5后,webpack命令失败

时间:2017-11-03 23:17:22

标签: angular visual-studio webpack asp.net-core angular5

我的项目在dot net core 2.0上运行,角度为4.2。 我将它更新为最新的角度(5.0.0)。 从那时起,在startup.cs Configure方法中抛出异常。

 app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
 {
     HotModuleReplacement = true
 });

此处出现错误

Error: Version of @angular/compiler-cli needs to be 2.3.1 or greater. 
Current version is "5.0.0".
at Object.<anonymous> (D:\Personal\Code\PettlyUi\PettlyUi\node_modules\@ngtools\webpack\src\index.js:27:11)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)

当我从命令行使用webpack时也会抛出相同的错误。

我也尝试了同样的新项目,但一直都失败了。这是某种错误还是我没有正确更新。

用于升级的命令:

npm install @angular/common@latest @angular/compiler@latest 
@angular/compiler-cli@latest @angular/core@latest @angular/forms@latest 
@angular/http@latest @angular/platform-browser@latest @angular/platform-
browser-dynamic@latest @angular/platform-server@latest 
@angular/router@latest @angular/animations@latest typescript@latest

1 个答案:

答案 0 :(得分:12)

由于没有答案,我会写出解决问题的方法

可能会出现此问题,因为Angular已更新至5.0.0版但 ngtools 仍旧更新。这会导致webpack命令失败。使用此命令将webpack更新为最新版本,

npm install --save-dev @ngtools/webpack@latest

错误错误地尝试指向旧的compiler-cli版本,显然不是这种情况。