升级到 angular 5 webpack 命令失败后 [英] After upgrading to angular 5 webpack command is failing

查看:25
本文介绍了升级到 angular 5 webpack 命令失败后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目在 dot net core 2.0 和 angular 4.2 上运行.我将其更新为最新的角度(5.0.0).从那以后,在 startup.cs Configure 方法中的这一行抛出异常.

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
 });

此处失败并出现错误

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 时也会抛出同样的错误.

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.

用于升级的命令:

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

发生此问题的原因可能是 Angular 已更新至 5.0.0 版,但 ngtools 仍较旧.这会导致 webpack 命令失败.使用这个命令更新 webpack 到最新,

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

错误试图指向旧的编译器 cli 版本,这显然不是这种情况.

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

这篇关于升级到 angular 5 webpack 命令失败后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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