在使用节点compile.js运行我的compile.js文件时,我面临一个问题。我的代码:
const async = require('asyncawait/async');
const await = require('asyncawait/await');
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile');
const provider = new HDWalletProvider(
'nut plug quality level uncle jeans retire guide eagle gossip cluster sudden',
'https://rinkeby.infura.io/v3/37097b2064214600912ad8a746ff433a'
);
const web3 = new Webs(provider);
const deploy = async (() => {
const accounts = await (web3.eth.Accounts());
console.log('Attempting to deploy from account', accounts[0]);
const result = await(new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: bytecode, arguments: ['Hi there!'] })
.send({gas: '1000000', from: accounts[0]})
);
console.log('contract deployed to', result.options.address);
});
deploy();运行后:节点compile.js
错误日志:
/home/edureka/sankalp_practice/inbox/node_modules/eth-block-tracker/src/index.js:38
async awaitCurrentBlock () {
^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/edureka/sankalp_practice/inbox/node_modules/web3-provider-engine/index.js:4:25)
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)
at Module.require (module.js:497:17)我做了我的分析,似乎"const HDWalletProvider =HDWalletProvider(‘块菌-hd钱包-provider’);“正在调用HDWalletProvider中的函数异步awaitCurrentBlock ()。
所以请让我知道如何解决这个问题。
系统: Ubuntu版本的节点: v6.11.4版本的npm : 5.4.2
发布于 2018-08-26 14:05:53
您的依赖项使用类似于节点8的“异步awaitCurrentBlock”。在这种情况下,您只是使用太旧版本的节点。您想要这个依赖项,那么您必须更新,但这将破坏您的代码以另一种方式--您正在导入依赖项“异步”和“等待”,这些都是Node 8中的保留关键字,因此您也必须更新语法。
https://stackoverflow.com/questions/52026954
复制相似问题