Angular 4到5更新./node_modules/@angular/core/esm5/core.js中的警告 [英] Angular 4 to 5 update WARNING in ./node_modules/@angular/core/esm5/core.js
问题描述
我已根据此教程,此后,我在webpack上构建失败,并发出两个警告:
I have updated Angular 4 to 5 according to this tutorial, after this my build failed on webpack with two warnings:
WARNING in ./node_modules/@angular/core/esm5/core.js
6553:15-36 Critical dependency: the request of a dependency is an expression
@ ./node_modules/@angular/core/esm5/core.js
@ ./ClientApp/boot.browser.ts
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
WARNING in ./node_modules/@angular/core/esm5/core.js
6573:15-102 Critical dependency: the request of a dependency is an expression
@ ./node_modules/@angular/core/esm5/core.js
@ ./ClientApp/boot.browser.ts
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
我经历了这个主题,但没有任何帮助(也许我错过了一些东西).这是我的webpack.config.vendor.js插件的外观:
I went through this topic, but nothing helps (maybe I miss something). This is how my webpack.config.vendor.js plugins look:
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', Popper: 'popper.js' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
]
我最初将Angular模板与Visual Studio中的.NET Core API一起使用.
I originally use Angular template with .NET Core API from Visual Studio.
推荐答案
在使用VS 2017附带的较新的Angular模板并将Angular版本4升级到5.xx时,需要运行以下命令为了避免在编译时收到一些警告.
When you are using the newer Angular template that now comes with VS 2017, and you upgrade Angular version 4 to 5.x.x, you need to run the following command in order to avoid some warnings you get at compile time.
webpack --config webpack.config.vendor.js
在项目的根目录下从命令提示符处运行此命令会删除您在上面的OP中看到的警告.
Running this from the command prompt while at the root of the project removes the warnings that you see in the OP above.
此操作是在 wwwroot/dist 文件夹中重建 vendor.js 文件,以根据已安装的Angular(和其他)npm软件包对其进行更新.
What this does is rebuild the vendor.js file in the wwwroot/dist folder to update it based on the Angular (and other) npm packages you have installed.
这篇关于Angular 4到5更新./node_modules/@angular/core/esm5/core.js中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!