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
Update:
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
web3.js
from github dist with similar results.dist
file and directly reference it? Like,require('./web3.dist.js');
? The./
ensures it does a direct file lookup beforenode_modules
.--bare
project at the latest Meteor version.meteor npm install --save web3
. Same problem persists.meteor-node-stubs
npm package. This had a dependency conflict with web3 (candidate package iscrypto-browserify
). After re-adding themeteor-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?