TypeError: require is not a function (webpack + faunadb)

June 29, 2017

This error comes up when using faunadb’s driver for nodejs with webpack.

Adding the following to webpack.config.js fixed the issue:

plugins: [
  new webpack.DefinePlugin({ "global.GENTLY": false })
],
node: {
  __dirname: true,
},
alias: {
  'inherits': 'inherits/inherits_browser.js',
  'superagent': 'superagent/lib/client',
  'emitter': 'component-emitter',
},

Here’s the issue and fix: https://github.com/felixge/node-formidable/issues/337#issuecomment-264337905.

Made it this far? Have a go at the game of snake