在将Web3从1.0.0-beta.34
上传到1.0.0-beta.37
后尝试访问Web3.utils
,Web3.eth
,Web3.bzz
和Web3.shh
的任何属性都会出错。例如,在web3.utils.utf8ToHex('some string')
调用2_deploy_contract.js
如下:
const Web3 = require('web3');
web3.utils.utf8ToHex('some string');
引发以下异常:
> TypeError: Cannot read property 'utf8ToHex' of undefined
我发现以下代码片段:
const Web3 = require('web3');
console.log("Web3.eth = " + Web3.eth)
console.log("Web3.utils = " + Web3.utils)
console.log("Web3.bzz = " + Web3.bzz)
console.log("Web3.shh = " + Web3.shh)
将输出:
> Web3.eth = undefined
> Web3.utils = undefined
> Web3.bzz = undefined
> Web3.shh = undefined