webpack dev服务器无法正常工作

时间:2016-05-19 10:47:49

标签: webpack webpack-dev-server

我有一个webpack.config.js这样的文件:

var path = require('path')
var webpack = require('webpack');

module.exports = {
    entry: "./index.js",
    output: {
        path: path.join(__dirname, 'static'),
        filename:'bundle.js'
    },
    module: {
        loaders: [
            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
            { test: /\.json$/, loader: 'json-loader' },
        ]
    }
};

和我的package.json就像:

"scripts": {
    "test": "mocha --compilers js:babel-register --recursive tests/*.js",
    "test:watch": "npm test -- --watch",
    "build": "webpack --progress --profile --colors",
    "build:watch": "webpack --progress --profile --colors --watch",
    "start": "webpack-dev-server"

但是当我运行npm run start时,它会给我错误的说法..

events.js:141
      throw er; // Unhandled 'error' event

这里有什么问题?

1 个答案:

答案 0 :(得分:1)

启动webpack dev服务器时可能是“端口”问题。试试webpack-dev-server --port 3000