继续保持断开连接! 错误

在这里输入图像描述

我目前正在开始使用ReactJs。 不过,我在控制台中遇到了以下错误,它不会在terminal中显示:

[WDS] Disconnected!sock.onclose @ client?64c0:70EventTarget.dispatchEvent @ eventtarget.js:49(anonymous function)@main.js:356

abstract-xhr.js:128 GET http://127.0.0.0/sockjs-node/info?t=1461853324372 net :: ERR_CONNECTION_TIMED_OUT

它正在寻找我在本地和全球安装的“sockjs-node”,但是没有任何改变。 它不应该search“node_modules”文件夹吗?

这是我的configuration:

var webpack = require("webpack"); var path = require("path"); module.exports = { devtool: "inline-source-map", entry: [ "webpack-dev-server/client?http://127.0.0.0/", "webpack/hot/only-dev-server", "./src" ], devServer: { contentBase: "./public", hot: true, inline: true, quiet: false, noInfo: true, stats: { colors: true } }, output: { path: path.join(__dirname, "./public"), filename: "./assets/js/bundle.js" }, resolve: { modulesDirectrories: ["node_modules", "src"], extentions: ["", ".js"] }, module : { loaders: [ { test: /\.jsx?$/, exclude: "/node_modules/", loaders: ["react-hot-loader", "babel?presets[]=react,presets[]=es2015"] }, { test: /\.css$/, loader: "style-loader!css-loader" }, { test: /\.gif$/, loader: "url-loader?mimetype=image/png" }, { test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" }, { test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" } ] }, plugins: [ new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin(), new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify("development") } }) ] } 

任何帮助表示赞赏,并提前感谢。

       

网上收集的解决方案 "继续保持断开连接! 错误"

我是这样修好的

原样:

  entry: [ "webpack-dev-server/client?http://localhost:9090", "webpack/hot/only-dev-server", "./src/app" ], 

成为 :

  entry: [ "webpack-dev-server/client?http://127.0.0.0:8080", "webpack/hot/only-dev-server", "./src" ], 

这个问题似乎是你没有在webpack-dev-server/client?http://127.0.0.0/包含端口号webpack-dev-server/client?http://127.0.0.0/

改变这个

 entry: [ "webpack-dev-server/client?http://127.0.0.0/", "webpack/hot/only-dev-server", "./src" ], 

至:

 entry: [ "webpack-dev-server/client?http://127.0.0.0:8080/", "webpack/hot/only-dev-server", "./src" ], 

您不需要更改webpack.config.js

尝试在package.json修复(在端口3000上启动服务器 ,而不是标准 8080):

 "start": "./node_modules/.bin/webpack-dev-server --host localhost --port 3000 --content-base src --inline --hot", 

index.htm更改path:

  <link rel="stylesheet" href="./main.css"> <script src="./main.js"></script> 

  <link rel="stylesheet" href="/main.css"> <script src="/main.js"></script>