New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
guidosegni opened this Issue Jul 31, 2017 · 50 comments

Comments

Projects
None yet
@guidosegni

guidosegni commented Jul 31, 2017

Using 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.

Any Idea? Am i doing something wrong?

@Moejoe90

This comment has been minimized.

Moejoe90 commented Aug 1, 2017

I'm having the same issue apparently, when i try to install the needed file manually i get only an older version

@jdkanani

This comment has been minimized.

jdkanani commented Aug 2, 2017

I am having same issue. @frozeman

@cowpig

This comment has been minimized.

cowpig commented Aug 2, 2017

having the same issue

@frozeman

This comment has been minimized.

Member

frozeman commented Aug 3, 2017

It was a package renaming issue, i fixed in the latest beat.15

@frozeman frozeman closed this Aug 3, 2017

frozeman added a commit that referenced this issue Aug 3, 2017

@jefflau

This comment has been minimized.

jefflau commented Aug 4, 2017

I just installed web3 today and I am also getting this issue. Is this already on npm?

Getting this error:

./~/web3/packages/web3-core/src/index.js
Module not found: Can't resolve 'web3-core-requestmanager' in '/Users/jefflau/Projects/dapps/meth-wallet/node_modules/web3/packages/web3-core/src'


@jefflau

This comment has been minimized.

jefflau commented Aug 4, 2017

Not sure what happened but the error disappeared. Maybe have something to do with metamask? After that error disappeared i couldn't get it working in metamask, but it works in Mist fine

@youfoundron

This comment has been minimized.

youfoundron commented Aug 9, 2017

@jefflau any idea of what might have fixed it? Getting this issue when I install truffle-contract.

@frozeman

This comment has been minimized.

Member

frozeman commented Aug 9, 2017

I forgot to publish this module. i published it, so the issue should go away.

@frozeman

This comment has been minimized.

Member

frozeman commented Aug 9, 2017

Truffle is and should not using the latest web3.js 1.0 beta, as its -> beta :)
@tcoulter you should definitely take look at it though :)

@youfoundron

This comment has been minimized.

youfoundron commented Aug 9, 2017

Looks like truffle-contract is looking for web3 internal packages by names no longer on the npm registry, I moved my web3 version from ^1.0.0-beta.17 to 1.0.0-beta.15, removed node_modules, and re-npm installed to fix.

@frozeman

This comment has been minimized.

Member

frozeman commented Aug 10, 2017

That doesn't sound like a fix, and like i wrote truffle is probably not working with web3.js 1.0.0 yet

@jdkanani

This comment has been minimized.

jdkanani commented Aug 14, 2017

@frozeman I am still getting this error.

@jdkanani

This comment has been minimized.

jdkanani commented Aug 14, 2017

I think I found the problem. Checkout: yarnpkg/yarn#711

Yarn doesn't handle nested node_modules as npm does.

@pcjose

This comment has been minimized.

pcjose commented Aug 16, 2017

I added this in the .bashrc

NODE_PATH=${HOME}/node_modules

and the problem was solved.

@robert-zaremba

This comment has been minimized.

robert-zaremba commented Aug 18, 2017

@pcjose this somehow a workaround. I would like to keep all modules in my project directory. I've tried with:

NODE_PATH=<absolute-path-to-project-root>/node_modules

And it doesn't work.
I found the following hack: yarnpkg/yarn#711 (comment)

Is there any clean way to tell yarn to install / link all dependencies recursively?

@tcoulter

This comment has been minimized.

tcoulter commented Aug 18, 2017

@frozeman

Truffle is and should not using the latest web3.js 1.0 beta, as its -> beta :)

Just to clear up any issues here, we haven't switched to 1.0 yet (nothing we have should be using it now, or has in the past). But we will switch once released!

@stefanhuber

This comment has been minimized.

stefanhuber commented Aug 24, 2017

Unfortunately, I have this problem with beta18. I tried to use web3 inside an ionic app. The following errors I get:

Cannot find module "web3-core-requestmanager"

Error: Cannot find module "web3-core-requestmanager"
    at webpackMissingModule (http://localhost:8100/build/vendor.js:116468:86)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:116468:187)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.module.exports.version (http://localhost:8100/build/vendor.js:116365:12)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.191 (http://localhost:8100/build/main.js:44:63)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.262 (http://localhost:8100/build/main.js:222:75)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.213 (http://localhost:8100/build/main.js:163:73)

What should I do?

@jdkanani

This comment has been minimized.

jdkanani commented Aug 24, 2017

@stefanhuber

Please use npm install --save web3 instead of yarn add web3 as workaround of this bug!

Now, for webpack to work:

const { lstatSync, readdirSync } = require('fs');
const { join } = require('path');

// is directory
const isDirectory = source => lstatSync(source).isDirectory();
// get directories
const getDirectories = source => readdirSync(source).map(name => join(source, name)).filter(isDirectory);

const web3Modules = getDirectories(`${__dirname}/node_modules/web3/packages`); // web3 node_modules
const nodeModules = [`${__dirname}/node_modules`];
nodeModules.push(...web3Modules.map(m => join(m, 'node_modules')));

// in webpack rules use
resolve: {
    modulesDirectories: nodeModules,
]
@jdkanani

This comment has been minimized.

jdkanani commented Aug 24, 2017

By the way, for webpack to work, this request #1006 needs to get merged too.

@stefanhuber

This comment has been minimized.

stefanhuber commented Aug 24, 2017

thanks for your fast reply. I use npm and not yarn. It seems that my problem really has todo with webpack...

@jdkanani

This comment has been minimized.

jdkanani commented Aug 24, 2017

@stefanhuber Try adding extra module directories in webpack resolve as I mentioned above #966 (comment) and see if works?

@stefanhuber

This comment has been minimized.

stefanhuber commented Aug 24, 2017

@jdkanani thank you for your solution. However I have no idea where I should add this script. Could you a little bit more specific on that?

@jdkanani

This comment has been minimized.

jdkanani commented Aug 24, 2017

@stefanhuber Add that script (or javascript equivalent) into your webpack.config.js. It just creates array with extra module paths to resolve imports for webpack.

nodeModules will have something like this:

[
'/Users/stefanhuber/...yourprojectpath.../node_modules',
'/Users/stefanhuber/...yourprojectpath.../node_modules/web3/packages',
'/Users/stefanhuber/...yourprojectpath.../node_modules/web3/packages/web3-core/node_modules',
'/Users/stefanhuber/...yourprojectpath.../node_modules/web3/packages/web3-core-requestmanager/node_modules',
.....
.....
]

Now you assign that array to your webpack rules (in js/jsx loader) in webpack.config file.

@stefanhuber

This comment has been minimized.

stefanhuber commented Aug 24, 2017

@jdkanani ok I managed to organize this inside the webpack and it seems to work.

web3.version is 1.0.0-beta.18, however the object web3.eth.contract is undefined. is there a different api?

TypeError: window.web3.eth.contract is not a function
    at http://localhost:8100/build/main.js:71:44
    at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9967)
    at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4499:37)
    at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9888)
    at r.runTask (http://localhost:8100/build/polyfills.js:3:5143)
    at invoke (http://localhost:8100/build/polyfills.js:3:10945)
    at n (http://localhost:8100/build/polyfills.js:2:28549)
@cmditch

This comment has been minimized.

cmditch commented Aug 24, 2017

@varadarajana

This comment has been minimized.

varadarajana commented Aug 27, 2017

I just added
export NODE_PATH=path/yo/node modules
and web3 gets loaded. THis is same as commented by @pcjose

@eafelix

This comment has been minimized.

eafelix commented Nov 28, 2017

Someone still has this issue?
It still appears in the last version "web3": "^1.0.0-beta2"

@davesag

This comment has been minimized.

davesag commented Dec 5, 2017

This just started happening to me this morning trying to start truffle develop.

Running web3 1.0.0-beta2
npm outdated reports the latest as being 1.0.0-beta.26

Now I'm confused as to which is actually the most recent. Either way I tried installing 1.0.0-beta.26 instead and I get the same error. Running Truffle 4.0.1

@bwheeler96

This comment has been minimized.

bwheeler96 commented Dec 6, 2017

@davesag I've downgraded to web3.js 0.20.2

Bottom line: web3 is in fucking shambles. There are a billion versions of every method across a bunch of "beta" releases, the "beta" is the default from the npm registry, and the documentation is fragmented.

Use anything else if you can

@icetique

This comment has been minimized.

icetique commented Dec 10, 2017

To fix:
Error: Cannot find module 'web3-requestManager'

Try installing specified, latest version. The problem seems to be that npm is confused what version is the latest and also not all dependencies work. When you run npm outdated and it seems like this:

Package           Current        Wanted         Latest  Location
web3          1.0.0-beta2   1.0.0-beta2  1.0.0-beta.26

It may not work. Your current version should match the latest version, so use:
npm install web3@1.0.0-beta.26

Your npm outdated will show you that you don't have the wanted version:
web3 1.0.0-beta.26 1.0.0-beta2 1.0.0-beta.26

But it works. I don't know why the people who package web3 didn't see there is clearly a problem. Maybe they know some workaround? It seems that node is stripping out the '6' at the end of the wanted version so if you run npm install web3 it install latest version of web3, but is considering it as '1.0.0-beta2' which does not resolve some dependencies.

Works for me, but I am not using truffle. Are you sure you are updating the web3 in the npm directory that truffle uses? Also, you may try uninstall web3 first and install specified version.

@wildmolasses

This comment has been minimized.

wildmolasses commented Dec 16, 2017

FYI, I had this problem. Here's what caused the problem.

  1. upgraded node
  2. tried to start my project, ran into a scrypt compile error.
  3. did npm update

My web3 submodules were then deleted.

To bring them back, I removed and then reinstalled web3.

@lsaether

This comment has been minimized.

lsaether commented Jan 19, 2018

This error still persists. As others have pointed out, NPM seems to be downloading web3@1.0.0-beta2 in place of web3@1.0.0-beta.2*.

In my case I'm trying to distribute a package that uses web3@1.0.0-beta.28 to users over NPM. The package will download the wrong web3 version anytime someone tries to install my package. It is unfortunate, but I am forced to downgrade to the stable version for now until a workaround is found...

@cosminstefanxp

This comment has been minimized.

cosminstefanxp commented Jan 21, 2018

Same issue while trying to deploy a code that uses web3 to Firebase Functions. @frozeman, any updates?

@srameshr

This comment has been minimized.

srameshr commented Jan 22, 2018

Stuck with this. npm install web3 installs 0.2 version. It does not even support promises. Fix this please. Its painful to trace a callback is not defined error from web3 till this thread to find out npm is not fetching 1.0.x version.

@bent0b0x

This comment has been minimized.

bent0b0x commented Jan 25, 2018

Any chance this may be resolved soon? I am also stuck having to use an ugly workaround 😅 .

Thanks!

@elijahmurray

This comment has been minimized.

elijahmurray commented Feb 15, 2018

Still appears to be happening…why is this closed? Tried everything in this thread with no luck.

@vsdigitall

This comment has been minimized.

vsdigitall commented Feb 16, 2018

The same thing after npm update, web3 updates to web3@1.0.0-beta2 instead of current web3@1.0.0-beta30

However reinstalling helps:

npm r web3
npm i web3
@daniyalzade

This comment has been minimized.

daniyalzade commented Mar 13, 2018

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

@shuji-koike

This comment has been minimized.

shuji-koike commented Mar 14, 2018

I came across a same problem after I did yarn upgrade.
As @daniyalzade has mentioned above, "pinning" the version explicitly (without ^ or ~) in package.json could be a workaround.

  "dependencies": {
    "web3": "1.0.0-beta.31"
  }

Seems like the version 1.0.0-beta2 which not having a "dot" after beta is somehow confusing yarn to resolve the latest version.

@roppa

This comment has been minimized.

roppa commented Mar 14, 2018

I'm getting this in 1.0.0-beta.31, but it works with 1.0.0-beta.30

@arashkiani

This comment has been minimized.

arashkiani commented Mar 23, 2018

going back to 1.0.0-beta.30 didnt work for me, but removing ^ did

@ondratra

This comment has been minimized.

ondratra commented Mar 27, 2018

I had same issue but changing to fixed old version didn't help. Then I realized I am using very new version of Ganache that itself depended on new Web3.js version, thus overriding my package.json Web3js version.

@roschler

This comment has been minimized.

roschler commented Apr 1, 2018

I had the exact same problem. I needed to retrieve the Web3.js package directly from the develop branch on GitHub to fix the following error that was being thrown when I tried to run the Node.JS app:

module.js:549
throw err;
^

Error: Cannot find module 'web3-requestManager'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/home/robert/Documents/ethereum-demo-tools/VOTING-APP/chat-vote-results-nodejs-app/node_modules/web3/packages/web3-core/src/index.js:26:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Waiting for the debugger to disconnect...

This the command I used to do that. It took a fair amount of time to complete so for a while I thought the install had hung. It took almost 10 minutes to fully install:

npm install ethereum/web3.js#develop --save --verbose

After that I was able to run my Node.js app.

@nickjuntilla

This comment has been minimized.

nickjuntilla commented Apr 24, 2018

For deploying to firebase functions it seems they use yarn and removing the ^ allowed it to deploy successfully for me. Apparently yarn has trouble parsing this version syntax for nested dependencies.

@maginkgo

This comment has been minimized.

maginkgo commented May 18, 2018

@nickjuntilla thanks. It worked!

@sasikumar13

This comment has been minimized.

sasikumar13 commented Jun 7, 2018

thanks vsdigitall
my error cleared..
Error: Cannot find module 'web3-requestManager'

reinstalling helps:

npm r web3

npm i web3

@thecodermarcelo

This comment has been minimized.

thecodermarcelo commented Aug 10, 2018

I started getting this error after I ran npm update, I had to get the original package.json that was in my remote github, remove the local node_modules and then run: npm install

@wjmelements

This comment has been minimized.

Contributor

wjmelements commented Oct 12, 2018

I have seen this after npm audit fix which downgraded my web3 to the deprecated 1.0.0-beta2. The fix was to return to the non-broken version.

@HP213

This comment has been minimized.

HP213 commented Oct 20, 2018

npm install web3@1.0.0-beta.26, just go for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment