【发布时间】:2018-08-29 14:30:48
【问题描述】:
我的项目在 dot net core 2.0 和 angular 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
【问题讨论】:
-
全局安装的
angular-cli是什么版本?使用命令ng -v并更新帖子 -
cli 版本是 1.5,但是经过数小时的努力,我终于解决了我的问题,这个命令救了我,npm install --save-dev @ngtools/webpack@latest 看起来需要 ngtools/webpack更新。我之前尝试的就是这个, npm install --save webpack@latest 抱歉给大家带来麻烦
-
但我仍然对错误消息“需要 2.3.1 或更高版本。当前版本是“5.0.0”。”有疑问,它是否属于错误
-
没有。您可以在 TeamViewer 中使用吗?。
-
不能,因为它是官方代码,但你能建议如何证明它是合理的
标签: angular visual-studio webpack asp.net-core angular5