【问题标题】:Webpack Dev Server works on every browser except Chrome?Webpack Dev Server 适用于除 Chrome 之外的所有浏览器?
【发布时间】:2017-04-03 20:00:36
【问题描述】:

我已经使用以下设置设置了 webpack 开发服务器,它在 Firefox 和 Safari 上运行良好,但在 Chrome 上无法运行。

我收到这条消息:

无法访问此网站

localhost 拒绝连接。 在 Google 上搜索本地主机 3005 ERR_CONNECTION_REFUSED

webpack.config.js

const webpack = require('webpack');
const nodeEnv = process.env.NODE_ENV || "production";

module.exports = {
    entry: {
        filename: "./index.js"
    },
    output: {
        filename: "./build/bundle.js"
    },
    module: {
        loaders: [
            {   test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ['es2015', 'react']
                }
            }
        ]
    },
    devServer: {
        inline: true,
        contentBase: "public",
        port: 3005
    }
}

【问题讨论】:

  • 试试其他端口?
  • 尝试了 3000、3005、3015 没有运气。
  • 还有其他错误信息吗?在终端上,或者在浏览器控制台上?
  • 什么都没有,控制台中什么都没有,页面根本无法加载。
  • 很奇怪,因为相同的设置适用于 windows...但在我的 mac 上它可能不是 mac 问题?

标签: javascript reactjs webpack


【解决方案1】:

我遇到了同样的问题,并设法通过在我的 hosts 文件中添加一个新寄存器来解决它:

  • 使用具有 sudo 权限的文本编辑器打开 /etc/hosts
  • 将此行添加到文件中:

127.0.0.1 localhost

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多