8

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' } ]
  • wild guess.. delete the node_module, npm cache clean and then reinstall – VISHAL DAGA Mar 20 '17 at 16:21
  • I have the same basic problem. The only other references I could find were [this other stackoverflow question](http://stackoverflow.com/questions/43020296/react-share-util-inherits-is-not-a-function-webpack-2) and [this github issue](https://github.com/webpack/webpack/issues/1019) which contains some workarounds, though none worked for me. – Michael Plotke May 02 '17 at 14:01

0 Answers0