简体   繁体   English

WebPack在主页上显示tslint警告

[英]WebPack displaying tslint warning on main page

I've been upgrading to webpack 2, but now I cant display main page as I end up with the warning message: 我一直在升级到webpack 2,但是由于出现警告消息,我现在无法显示主页:

Failed to compile: 编译失败:

./src/app/login/login.component.ts [20, 21]: missing whitespace ./src/app/login/login.component.ts [20,21]:缺少空格

This is the one of the warning messages that I see in console, but it never stopped webpack server from displaying content before. 这是我在控制台中看到的警告消息之一,但它从未使Webpack Server停止显示内容。

In Console webpack says: "Compiled with warnings" so there should not be reason for displaying Failed to compile on the main page. 在控制台中,webpack表示:“已编译警告”,因此不应有理由在主页上显示“编译失败”。

It seems like you are executing a linter during compiling. 似乎您在编译期间正在执行lint。 It is ESLint or TSLint, depending on your programming language (Javascript/Typescript). 根据您的编程语言(Javascript / Typescript),它是ESLint或TSLint。 It skips compiling after the execution of the linter as it detected style issues in your code. 在执行linter之后,由于它在代码中检测到样式问题,因此跳过了编译。

Do you have any of these dependencies in your package.json? 您的package.json中是否有这些依赖项?

"devDependencies": {
        "eslint": "4.1.1",
        "eslint-loader": "1.8.0"
    }

Look in your webpack.config.js, there could be something like this defined which executes ESLint during compiling: 查看您的webpack.config.js,可能会有类似这样的定义,它会在编译期间执行ESLint:

module: {
   rules: [
           {
            enforce: "pre",
            test: /\.js$/,
            exclude: /node_modules/,
            loader: "eslint-loader"
           }
   ]
}

Please feel free to accept it as answer if it solves your problem. 如果可以解决您的问题,请随时接受它作为答案。

Finally fixed it :) 终于解决了:)

Actually it was a bug with webpack: https://github.com/webpack/webpack-dev-server/issues/861 实际上这是webpack的错误: https : //github.com/webpack/webpack-dev-server/issues/861

Work around is to set: 解决方法是设置:

devServer: {
  overlay: {
    warnings: false,
    errors: true
  }
}

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

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