我在跑:
我做了折叠的步骤:
geth --testnet --rpcnpm install web3 -g安装。node (控制台)console.log(web3);我知道错误:
ReferenceError: web3 is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)当我在节点控制台中运行require('web3')时,我会得到相同的错误。
我还尝试安装没有web3的-g (npm install web3);同样的结果。
我做错了什么?为什么在通过web3安装之后,节点无法识别npm install web3 -g?
我试图按照以下线程进行安装:如何将NodeJS连接到Ethereum网络?
发布于 2016-10-24 16:20:04
您需要先实例化它。在节点类型中的npm install web3之后:
var web3 = require('web3');然后console.log(web3)将输出
{ [Function: Web3]
providers: { HttpProvider: [Function], IpcProvider: [Function] } }
undefined欲了解更多信息,请阅读:https://www.npmjs.com/package/web3
发布于 2016-10-24 16:16:40
Windows问题,NODE_PATH没有正确指向节点模块目录。现在起作用了。
https://ethereum.stackexchange.com/questions/9565
复制相似问题