<
 
 
 
 
×
>
hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 22:08:41 Jun 18, 2021, and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

Cannot find module 'web3'

caylorcaylor Member Posts: 25 ✭✭
Hi, I'm trying to install the ethereum.js package but I cannot seem to get the require to work. I've run the following


ccc:~/code$ mkdir eth2
ccc:~/code$ cd eth2
ccc:~/code/eth2$ mkdir node_modules
ccc:~/code/eth2$ node --version
v0.13.0-pre
ccc:~/code/eth2$ npm --version
1.4.28
ccc:~/code/eth2$ npm install ethereum.js
/
> [email protected] install /home/chris/code/eth2/node_modules/ethereum.js/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

[email protected] node_modules/ethereum.js
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected])
ccc:~/code/eth2$ node
> e=require('web3')
Error: Cannot find module 'web3'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at repl:1:3
at REPLServer.defaultEval (repl.js:133:27)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer. (repl.js:280:12)
at REPLServer.emit (events.js:107:17)


It looks like there was some error during the install. The following was in the builderror.log file


gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:66:16)
gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:152:20)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:95:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:723:7)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at maybeClose (child_process.js:1000:16)
gyp ERR! stack at Socket. (child_process.js:1168:11)
gyp ERR! stack at Socket.emit (events.js:107:17)
gyp ERR! stack at Pipe.close (net.js:461:12)
gyp ERR! System Linux 3.13.0-40-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/chris/code/eth2/node_modules/ethereum.js/node_modules/ws
gyp ERR! node -v v0.13.0-pre
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok


Any ideas?

Comments

  • caylorcaylor Member Posts: 25 ✭✭
    For anyone struggling with this, it seems that you need to specify the path to your node installation when using npm install:

    npm install --nodedir=~/node ethereum.js

    It seems the install was semi-successful this time except the builderrorlog now contains some warnings. I'm assuming these don't really matter.


    child_process: customFds option is deprecated, use stdio instead.
    ../src/bufferutil.cc: In static member function ‘static void BufferUtil::Initialize(v8::Handle)’:
    ../src/bufferutil.cc:32:17: warning: ‘v8::Local NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:611) [-Wdeprecated-declarations]
    target->Set(NanSymbol("BufferUtil"), t->GetFunction());
    ^
    ../src/bufferutil.cc:32:39: warning: ‘v8::Local NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:611) [-Wdeprecated-declarations]
    target->Set(NanSymbol("BufferUtil"), t->GetFunction());
    ^
    ../src/validation.cc: In static member function ‘static void Validation::Initialize(v8::Handle)’:
    ../src/validation.cc:112:17: warning: ‘v8::Local NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:611) [-Wdeprecated-declarations]
    target->Set(NanSymbol("Validation"), t->GetFunction());
    ^
    ../src/validation.cc:112:39: warning: ‘v8::Local NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:611) [-Wdeprecated-declarations]
    target->Set(NanSymbol("Validation"), t->GetFunction());
    ^


    I have a test.js file in my main directory that contains

    require('web3'); console.log('hiya');

    However, I still get the message Cannot find module 'web3'. Any help would be appreciated.
  • PranayPranay Member Posts: 58
    did you get it working?
  • PranayPranay Member Posts: 58
  • StartUpsPalStartUpsPal Member Posts: 2
    caylor said:

    Hi, I'm trying to install the ethereum.js package but I cannot seem to get the require to work. I've run the following


    ccc:~/code$ mkdir eth2
    ccc:~/code$ cd eth2
    ccc:~/code/eth2$ mkdir node_modules
    ccc:~/code/eth2$ node --version
    v0.13.0-pre
    ccc:~/code/eth2$ npm --version
    1.4.28
    ccc:~/code/eth2$ npm install ethereum.js
    /
    > [email protected] install /home/chris/code/eth2/node_modules/ethereum.js/node_modules/ws
    > (node-gyp rebuild 2> builderror.log) || (exit 0)

    [email protected] node_modules/ethereum.js
    ├── [email protected]
    ├── [email protected]
    └── [email protected] ([email protected], [email protected], [email protected])
    ccc:~/code/eth2$ node
    > e=require('web3')
    Error: Cannot find module 'web3'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at repl:1:3
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer. (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)


    It looks like there was some error during the install. The following was in the builderror.log file


    gyp ERR! configure error
    gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
    gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:66:16)
    gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
    gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:152:20)
    gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:95:9
    gyp ERR! stack at ChildProcess.exithandler (child_process.js:723:7)
    gyp ERR! stack at ChildProcess.emit (events.js:110:17)
    gyp ERR! stack at maybeClose (child_process.js:1000:16)
    gyp ERR! stack at Socket. (child_process.js:1168:11)
    gyp ERR! stack at Socket.emit (events.js:107:17)
    gyp ERR! stack at Pipe.close (net.js:461:12)
    gyp ERR! System Linux 3.13.0-40-generic
    gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /home/chris/code/eth2/node_modules/ethereum.js/node_modules/ws
    gyp ERR! node -v v0.13.0-pre
    gyp ERR! node-gyp -v v1.0.1
    gyp ERR! not ok


    Any ideas?

    Any update on this?
  • caylorcaylor Member Posts: 25 ✭✭
    You can see I partially solved it in the second comment. However, this is likely out of date as it was written long ago. I think the problem not being able to find web3 is solved by running a copy of eth in another terminal and using RPC to connect...
  • hizia18hizia18 Member Posts: 10
    I'm having the same issue apparently, when i try to install the needed file manually i get only an older version ..
Sign In or Register to comment.