Created new --bare Meteor project (release 1.8).

Used meteor npm install --save web3 to add web3 to the project from npmjs.org.

In code server.js use:

Web3 = require('web3')
console.log(Web3) // returns '{}'

Nothing else added to Meteor project. Client side use is as expected.

Toolkit: MacOS, Ganache, Truffle, Web3 version 1

I did of course discover that this can be a consequence of recursion in package dependencies

Is this a known issue? Is it a bug? What would be the best direction to go in determining the root cause of this issue?

Related SO Questions/Threads:

Meteor server side contract event watch error

Problem with meteor server side call to Ethereum node

Cannot find module 'web3' meteor

How do you connect to a node from the server side of a meteor app


After seeing many unresolved questions/issues on this, I've bumped an existing github issue for tracking. Additionally there is a Meteor Forums post, and I've created a post on the Ethereum Forums

  • Also tried using just the distributed library file web3.js from github dist with similar results. Commented Oct 10, 2018 at 15:41
  • It's obviously better to use NPM for this, but it doesn't even work when you include the dist file and directly reference it? Like, require('./web3.dist.js');? The ./ ensures it does a direct file lookup before node_modules.
    – ohsully
    Commented Oct 10, 2018 at 19:21
  • 1
    @ohsully yes the direct reference to the dist file is how I tested it. It works on just a node project, and from previous experience I have seen when package dependency recursion resulted in this effect for a different project and npm package I was working with. Therefore I assume there is some conflict with Meteor on the server side. It's interesting to note also that it is a new --bare project at the latest Meteor version. Commented Oct 11, 2018 at 9:28
  • 1
    Update: have installed both from npm and dist file in parallel, and can try to import/require either on server. Still a bare new empty meteor project, have only downloaded dist file and run meteor npm install --save web3. Same problem persists. Commented Oct 11, 2018 at 13:15
  • 1
    Update on solution progress: I have been able to get web3 functioning on both server and client in Meteor (1.7/1.8). This was accomplished by first removing meteor-node-stubs npm package. This had a dependency conflict with web3 (candidate package is crypto-browserify). After re-adding the meteor-node-stubs package after installing web3 in the project, the conflict seems to have been resolved. It seems that load order of dependencies may have been the problem. More testing needed to determine exactly the specific fix. Perhaps others can test this 'workaround' solution? Commented Oct 12, 2018 at 14:35

1 Answer 1


On further testing, there seems to be a consistent work around for getting the require of the Web3 package to work on the server in Meteor.

Tested procedure on both new and existing Meteor projects (version 1.7/1.8):

  1. Create a new meteor project (optional) or navigate to the directory of an existing project.
  2. In the Meteor project directory use meteor npm uninstall --save meteor-node-stubs.
  3. Next do: meteor npm install --save web3
  4. Now re-add meteor npm install --save meteor-node-stubs
  5. Do the normal import and instantiate the web 3 object as per documentation

The web3 instance should now be working as expected on the Meteor server which you can check after launching the app using meteor shell.

It seems there is an issue in the load order of conflicting dependency packages, with the candidate offending package being crypto-browserify.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.