Webpack-dev-server 2未捕获TypeError:util.inherits不是函数

时间:2017-03-20 16:04:09

标签: webpack webpack-dev-server webpack-2

我在编译时运行webpack-dev-server而不是控制台错误时遇到问题但是当我转到http://localhost:8080/时会在浏览器中抛出下一个错误:

未捕获TypeError:util.inherits不是函数。

很奇怪,因为没有webpack-dev-server的webpack也能正常工作。 当我调试错误时,错误在文件webpack:/// ./~/websocket-driver/lib/websocket/streams.js?875d中,错误是这段:

var Stream = require('stream').Stream,
    util   = require('util');


var IO = function(driver) {
  this.readable = this.writable = true;
  this._paused  = false;
  this._driver  = driver;
};
util.inherits(IO, Stream); // this line

webpack.config.js

[ { devtool: 'eval-source-map',
    resolve: { extensions: [Object], modules: [Object], alias: [Object] },
    module: { rules: [ { test: /\.css$/, use: [Object] },
 { test: /\.scss/, use: [Object] },
 { test: /\.json/, use: [Object] },
 { test: /\.(png|jpg|gif|woff|woff2)$/, use: [Object] },
 { test: /\.(mp4|ogg|svg)$/, use: [Object] },
 { test: /\.(js|jsx)$/,
   use: [Object],
   include: '/opt/inmoblex/current/inmoblex/src',
   exclude: /node_modules/ } ] },
    entry: [ './src/server.jsx' ],
    output:
     { path: '/opt/inmoblex/current/inmoblex/dist',
       filename: 'server.js',
       publicPath: '/static/' },
    target: 'node' },
  { devtool: 'eval-source-map',
    resolve: { extensions: [Object], modules: [Object], alias: [Object] },
    module: { rules: [ { test: /\.css$/, use: [Object] },
 { test: /\.scss/, use: [Object] },
 { test: /\.json/, use: [Object] },
 { test: /\.(png|jpg|gif|woff|woff2)$/, use: [Object] },
 { test: /\.(mp4|ogg|svg)$/, use: [Object] },
 { test: /\.(js|jsx)$/,
   use: [Object],
   include: '/opt/inmoblex/current/inmoblex/src',
   exclude: /node_modules/ } ] },
    entry: [ './src/client.jsx' ],
    output:
     { path: '/opt/inmoblex/current/inmoblex/dist',
       filename: 'client.js',
       publicPath: '/static/' },
    plugins: [],
    node:
     { fs: 'empty',
       child_process: 'empty',
       crypto: 'empty',
       net: 'empty',
       tls: 'empty' },
    devServer:
     { hot: true,
       contentBase: '/opt/inmoblex/current/inmoblex/cfg/src' },
    target: 'web' } ]

0 个答案:

没有答案