Webpack-dev-server 2 Uncaught TypeError: util.inherits is not a function

橙三吉。 提交于 2019-12-10 15:21:58

问题


I have a problem trying when i run webpack-dev-server not console error in compilation time but throws the next error in browser when i go to http://localhost:8080/:

Uncaught TypeError: util.inherits is not a function.

is strange beacause works well with webpack without webpack-dev-server. when i debug the error the error is in file webpack:///./~/websocket-driver/lib/websocket/streams.js?875d and the error is this segment:

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' } ]

来源:https://stackoverflow.com/questions/42908420/webpack-dev-server-2-uncaught-typeerror-util-inherits-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!