简体   繁体   English

与 Webpack 反应不显示错误

[英]React with Webpack not displaying errors

I'm running react with HMR using webpack.我正在使用 webpack 对 HMR 做出反应。 When a function is deleted in a server or used shared service is deleted, no errors are emitted, neither in the console nor on the terminal.在服务器中删除 function 或删除使用的共享服务时,无论是控制台还是终端都不会发出错误。 This error can not be seen even during the build process.即使在构建过程中也看不到此错误。

I've waisted at least a day trying to find a solution for it.我至少花了一天时间试图找到解决方案。 Any help is appreciated.任何帮助表示赞赏。

thank you.谢谢你。

const DEV_SERVER = {
    contentBase: PATHS.public,
    hot: true,
    open: true,
    hotOnly: true,
    historyApiFallback: true,
    overlay: true,
    port: 3000,
// stats: 'verbose',
// proxy: {
//   '/api': 'http://localhost:8888'
// },

More Details更多细节

if i have user.service.ts imported in an index.ts file and use in all the other files, then i delete the user.service.ts file.如果我在user.service.ts文件中导入了index.ts并在所有其他文件中使用,那么我删除了 user.service.ts 文件。

Expected Behaviour : An error with module not found.预期行为:找不到模块的错误。

Current Behaviour : Nothing is showing in the console or terminal.当前行为:控制台或终端中没有显示任何内容。

React v 16.13反应 v 16.13

Webpack v 4.41 Webpack v 4.41

Check the source maps used, this worked for me:检查使用的源地图,这对我有用:

devtool: 'cheap-module-source-map'

Did you try the error-overlay-webpack-plugin?您是否尝试过 error-overlay-webpack-plugin?

const ErrorOverlayPlugin = require("error-overlay-webpack-plugin");

module.exports =  {
    plugins: [new ErrorOverlayPlugin()]
);

https://www.npmjs.com/package/error-overlay-webpack-plugin https://www.npmjs.com/package/error-overlay-webpack-plugin

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

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