express配置webpack-dev-server 启动时报错

boy_is_god 发布于 2017/07/14 09:00
阅读 302
收藏 0

//--------------------报错----------------------

D:\A_Code\GitHub\React_Antd_Demo\node_modules\webpack-dev-server\lib\Server.js:34
        this.hot = options.hot || options.hotOnly;
                 ^

TypeError: Cannot set property 'hot' of undefined
    at Server (D:\A_Code\GitHub\React_Antd_Demo\node_modules\webpack-dev-server\lib\Server.js:34:11)
    at Object.<anonymous> (D:\A_Code\GitHub\React_Antd_Demo\server\server.js:18:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

//---------------server.js-------------

'use strict'

var express = require('express');

var app = express();

 

var path = require('path');

 

var webpack = require('webpack');

 

var webpackDevServer = require('webpack-dev-server');

 

var webpackDevConfig = require('../webpack.config.dev');

 

var LoadDatas = require('./loadDatas');

 

var compiler = webpack(webpackDevConfig);


 

app.use(webpackDevServer(compiler, {

hot: true,

historyApiFallback: true,

contentBase: path.resolve(__dirname, 'dist'),

// public path should be the same with webpack config

publicPath: webpackDevConfig.output.publicPath,

noInfo: true,

stats: {

colors: true

}

}));


 

var server = app.listen(8081, function () {

var host = server.address().address

var port = server.address().port

console.log("应用实例,访问地址为 http://%s:%s", host, port)

})

 

//-----------------webpack.config.dev.js------

 

 

加载中
返回顶部
顶部