webpack-dev-server热重装无法正常工作?

时间:2018-08-27 11:59:08

标签: javascript node.js reactjs react-native reactive-programming

在React中,我运行set.seed(12345) foo <- rnorm(1000) bar <- boxplot(foo, plot = FALSE) boxplot(foo, outline = FALSE, ylim = range(foo), horizontal = TRUE) points(bar$out, jitter(rep(1, length(bar$out)))) ,但出现此错误:this

我的文件结构:

package.json:

"start": "webpack-dev-server --hot"

App.jsx:

  {
    "name": "reactapp",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "webpack-dev-server --hot"
    },
    "author": "Sheharzad",
    "license": "ISC",
    "dependencies": {
        "babel-core": "^6.26.3",
        "babel-loader": "^7.1.5",
        "babel-preset-es2015": "^6.24.1",
        "babel-preset-react": "^6.24.1",
        "react": "^16.4.2",
        "react-dom": "^16.4.2",
        "webpack": "^4.17.1",
        "webpack-dev-server": "^3.1.6"
    }
  }

main.js:

import React from 'react';

class App extends React.Component {
   render() {
      return (
         <div>
            Hello World!!!
         </div>
      );
   }
}
export default App;

1 个答案:

答案 0 :(得分:1)

听您尚未添加接受--hot标志的 webpack cli 软件包。添加此程序包后,请尝试。它应该工作。让我知道是否有帮助。

已编辑"start" : "webpack-dev-server --mode development --config webpack.config.js --open --hot:

确保您的根文件夹中有webpack配置,然后重新启动开发服务器。