After upgrading to angular 5 webpack command is failing

假装没事ソ 提交于 2019-12-20 10:45:06

问题


My project was running on dot net core 2.0 with angular 4.2. I update it to latest angular (5.0.0). Since then, exception is thrown at this line in a startup.cs Configure method.

 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.

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

回答1:


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. This causes webpack command to fail. Use this command to update webpack to latest,

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

The error incorrectly tries to point to old compiler-cli version, which is clearly not the case.



来源:https://stackoverflow.com/questions/47105660/after-upgrading-to-angular-5-webpack-command-is-failing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!