简体   繁体   English

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

[英]After upgrading to angular 5 webpack command is failing

My project was running on dot net core 2.0 with angular 4.2. 我的项目运行在dot net core 2.0上,角度为4.2。 I update it to latest angular (5.0.0). 我将它更新为最新的角度(5.0.0)。 Since then, exception is thrown at this line in a startup.cs Configure method. 从那时起,在startup.cs Configure方法中抛出异常。

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

Fails here with error 这里因错误而失败

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)

The Same error is thrown when I use webpack from the command line too. 当我从命令行使用webpack时也会抛出相同的错误。

I tried the same with new projects also and it consistently fails. 我也尝试过同样的新项目,但一直都失败了。 Is this some kind of bug or I have not updated properly. 这是某种错误还是我没有正确更新。

Command used for upgrading: 用于升级的命令:

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

Since there are no answers, I will write what fixed my problem 由于没有答案,我会写出解决问题的方法

This issue may occur because Angular is updated to version 5.0.0 but ngtools is still older. 可能会出现此问题,因为Angular已更新到版本5.0.0但ngtools仍然更旧。 This causes webpack command to fail. 这会导致webpack命令失败。 Use this command to update webpack to latest, 使用此命令将webpack更新为最新版本,

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

The error incorrectly tries to point to old compiler-cli version, which is clearly not the case. 错误错误地尝试指向旧的compiler-cli版本,显然不是这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM