React-instantsearch: Uncaught TypeError: util.inherits is not a function

Created on 19 Jul 2017  路  12Comments  路  Source: algolia/react-instantsearch

Trying to use the lib.

import React, {Component} from 'react'
import classnames from 'classnames'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import Autosuggest from 'react-autosuggest';
import {mouseTrap} from 'react-mousetrap';
import BZModal from 'BZModal';
import _ from 'underscore';
import {
    Configure,
    InstantSearch,
    Index,
    Highlight,
    SearchBox
} from 'react-instantsearch/dom';
import {
     connectHits,
     connectAutoComplete
 } from 'react-instantsearch/connectors';
import PubSub from '../PubSub';

image

But getting this error on the client.
Happens on Chrome.
We are using webpack 1.15.0
Npm 5.0.2
React 15.6.1
Node 6.9.2

image

image

鉂わ笍 Bug

Most helpful comment

@mthuret I fixed it with the following code:
node-libs-browser is using inherits 2.0.1.
It's a Webpack bug.

npm i [email protected] --save

Adding to webpack
resolve: { alias: { util$: path.resolve(__dirname, 'node_modules/util') } }

All 12 comments

Hi @danielbentov, could you give us a small repo reproducing the issue you're facing as it would be easier for us to understand.

Thanks in advance!

Hi @mthuret,
I can not create a repo that will mimic our product (we have 5 years of code there).
I can tell you that it seems that working with node 6.11.0 and Webpack caused the issue.
You are using util.inherits in your code.

https://github.com/webpack/webpack/issues/1019
https://github.com/defunctzombie/node-util/issues/17
Until then we can't use your lib in our product.

I didn't succeed reproducing the issue based on webpack 2 and node 6.11.0. I'm also confused because you indicate that you're using webpack 1.15.0 and node 6.9.2?

@bobylito, as it seems to be related to helper, did you already encounter this issue?

Also @danielbentov, can you indicate which version of react instantsearch you are using. And if you're not using 4.1.0-beta.2, can you try with it?

Still happening with 4.1.0-beta.2

image

@mthuret I fixed it with the following code:
node-libs-browser is using inherits 2.0.1.
It's a Webpack bug.

npm i [email protected] --save

Adding to webpack
resolve: { alias: { util$: path.resolve(__dirname, 'node_modules/util') } }

@danielbentov awesome! I'm closing this, then.

Don't hesitate to reach to us again for any questions about the lib :)

I still get the same error, it didn't help.

@VapiSoft please make a new issue with reproduction

module.exports = {
  resolve: {
    mainFields: ['browser', 'module', 'main']
  }
};

Adding this to the webpack config solved it for me.

We haven't been using util for a while now, which version of React InstantSearch did you have this issue with @markpradhan ?

Ah my bad, i found this thread looking for an answer, thought it would help if people still had this issue as it looks very similar to whatever i was experiencing (issue in react-pdf). I am not using instant search at all. Sorry for pinging you guys! @Haroenv

Was this page helpful?
0 / 5 - 0 ratings

Related issues

developerk786 picture developerk786  路  3Comments

danhodkinson picture danhodkinson  路  3Comments

denkristoffer picture denkristoffer  路  4Comments

tstehle picture tstehle  路  4Comments

flouc001 picture flouc001  路  5Comments