将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