Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ethereum Web3.js returns "Cannot find module 'web3-requestManager'"

I'm trying to start using Ethereum Web3.js with node 6.11.1 on a macosx

I installed web3 with the following command:

npm install web3

Then i launch this - apparently - simple node command:

Web3 = require('web3');

Well, it returns the following error:

module.js:471
    throw err;
    ^

Error: Cannot find module 'web3-requestManager'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/fremente/Dropbox/Influx Design/Web htdocs/ethereum/node_modules/web3/packages/web3-core/src/index.js:26:22)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

it looks like it require some module (e.g. 'web3-requestManager') that aren't installed with the package.

Here it is my package.json

{
  "name": "ethereum",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "ethereumjs-testrpc": "^4.0.1",
    "solc": "^0.4.13",
    "web3": "^1.0.0-beta2"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Any Idea? Am i doing something wrong?

like image 449
Umberto Stanca Avatar asked Jul 31 '17 22:07

Umberto Stanca


3 Answers

npm install ethereum/web3.js

should solve your problem

like image 63
Diego Avatar answered Nov 10 '22 10:11

Diego


The problem comes from using a beta version of web3 its not stable at the moment and currently is under heavy development you have one of two options,

  • either use a stable version 0.23 i think or something like that

  • or manually install all the needed dependencies i don't recommend this solution for a stable dapp since things are currently really unstable

like image 7
Moe Elsharif Avatar answered Nov 10 '22 08:11

Moe Elsharif


I solved it by removing node_modules folder, running npm install again and installing web3js manually in addition to package.json listing:

Add dependency to package.json

"web3": "^1.0.0-beta.31"

Rebuild modules

rm -rf node_modules
npm install

Install web3 manually

npm install [email protected]
like image 4
Dmitry T. Avatar answered Nov 10 '22 10:11

Dmitry T.