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

9

16

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?

Disfranchise answered 31/7, 2017 at 22:25 Comment(4)
Just for completion, there is an open issue with this problem at the git repo for the library: github.com/ethereum/web3.js/issues/966 – Ennius
I opened that issue πŸ˜‰ – Disfranchise
I solved installing the 0.4 version – Disfranchise
It was a package renaming issue, please add this in the .bashrc NODE_PATH=${HOME}/node_modules. and the problem will be solved. – Huge
E
8

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

Ensign answered 1/8, 2017 at 17:10 Comment(2)
It is very unstable at the moment, nonetheless I put together an example repo using Web.js v1.0-beta18 that does work (it has the correct dependencies): github.com/leopoldjoy/react-ethereum-dapp-example – Firer
You are correct like I stated in the solution above you can manually install all dependencies and web3 v1.0 will work, however, I noticed some edge cases even after installing all dependencies, to be honest problems like these are a clear indicator that web 1.0v shouldn't be used currently for any production code. – Ensign
N
16
npm install ethereum/web3.js

should solve your problem

Nystatin answered 7/11, 2017 at 12:44 Comment(1)
I had to use this first to clear that error above and then my meta mask account was not able to be found so I had to use [email protected] – J
E
8

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

Ensign answered 1/8, 2017 at 17:10 Comment(2)
It is very unstable at the moment, nonetheless I put together an example repo using Web.js v1.0-beta18 that does work (it has the correct dependencies): github.com/leopoldjoy/react-ethereum-dapp-example – Firer
You are correct like I stated in the solution above you can manually install all dependencies and web3 v1.0 will work, however, I noticed some edge cases even after installing all dependencies, to be honest problems like these are a clear indicator that web 1.0v shouldn't be used currently for any production code. – Ensign
J
4

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]
Januaryjanuisz answered 26/3, 2018 at 16:20 Comment(0)
I
2

Installing git on my Windows 10 machine helped. Dependencies did not install properly without it. https://git-scm.com/downloads

Infernal answered 27/4, 2018 at 13:21 Comment(0)
S
2

npm install ethereum/web3.js fixed my issue.

hope it works for you too.

Saudra answered 15/1, 2019 at 16:24 Comment(0)
J
0

I was facing this exact issue with: [email protected]

I have fixed this issue by upgrading node from v6.11.3 to v8.9.4.

I have removed node_modules folder and run: npm install to rebuild modules.

I think that web3 is using features that are only supported by node version 8.x.x.

Jotunheim answered 19/1, 2018 at 23:19 Comment(0)
L
0

I resolved the web3-requestManager issue by pinning to 1.0.0-beta.29 version. Previously it was installing 1.0.0-beta.2.

Legg answered 13/3, 2018 at 15:29 Comment(0)
B
0

I am currently using web3 1.0 version. And I am using macOS as well. If you are using this version too, try this:

Running npm install ethereum/web3.js
Balata answered 12/5, 2018 at 7:44 Comment(0)
E
0

Downgrading "react-scripts" from "5.0.0" to "4.0.3" did the trick for me.

Excellent answered 11/2, 2022 at 15:4 Comment(1)
Hello, please consider this question is more than 4 years old, the versions you're mentioning don't really match OP's environment. – Vedette

© 2022 - 2024 β€” McMap. All rights reserved.