horizon: Error when building with webpack

ERROR in ./~/@horizon/client/lib/util/fetch.js
Module not found: Error: Cannot resolve module 'exports' in ./node_modules/@horizon/client/lib/util
 @ ./~/@horizon/client/lib/util/fetch.js 13:0-69

Server Version: 1.0.1 Client Version: 1.0.1

Installed client with npm install @horizon/client

I am following the second option in the instructions for Integrating Horizon.

I’m seeing the error above. I installed @horizon/client and attempted to build it within my existing setup. Apparently this has something to do with the imports loader. Installing imports-loader in my project doesn’t fix the problem.

In fetch.js:

require('imports?this=>global!exports?global.fetch!isomorphic-fetch');

That is the problem line.

My code is exactly the example on the @horizon/client npm page:

const Horizon = require("@horizon/client")
const horizon = Horizon()

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same error and I’m not using webpack, I just tried to import it from node.

Installing the dependencies doesn’t fix it only commenting out the

require('imports?this=>global!exports?global.fetch!isomorphic-fetch');

I also ran into this. It was my mistake - we have to add import/exports loader not to devDependencies but dependencies. I can create a pr later.

A solution for now is to install exports-loader and imports-loader manually in the project where horizon is used.

EDIT: here https://github.com/rethinkdb/horizon/pull/437