Ethereum 无法从ganache提供程序获取帐户

Ethereum 无法从ganache提供程序获取帐户,ethereum,web3,web3js,truffle,ganache,Ethereum,Web3,Web3js,Truffle,Ganache,我正试图按照我关于以太坊区块链的课程中描述的步骤在摩卡上运行测试 这是我当前拥有的package.json文件: { "name": "inbox", "version": "1.0.0", "description": "", "main": "index", "typings": "index", "scripts": { "test": "mocha" }, "author": "", "license": "ISC", "dependenc

我正试图按照我关于以太坊区块链的课程中描述的步骤在摩卡上运行测试

这是我当前拥有的package.json文件:

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index",
  "typings": "index",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ganache-cli": "^6.3.0",
    "mocha": "^5.2.0",
    "solc": "^0.4.17",
    "web3": "^1.0.0-beta.37"
  }
}
当我运行:npm run test时,我遇到了以下问题:

 Inbox contract
Error: No callback provided to provider's send function. As of web3 1.0, provider.send is no longer synchronous and must be passed a callback as its final argument.
    at b.send (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\ganache-cli\build\ganache-core.node.cli.js:25:90931)
    at GetAccountsMethod._callee$ (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\web3-core-method\dist\web3-core-method.cjs.js:454:55)
    at tryCatch (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\regenerator-runtime\runtime.js:62:40)
    at Generator.invoke [as _invoke] (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\regenerator-runtime\runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\regenerator-runtime\runtime.js:114:21)
    at asyncGeneratorStep (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
    at _next (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
    at C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at GetAccountsMethod.<anonymous> (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)
    at GetAccountsMethod.execute (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\web3-core-method\dist\web3-core-method.cjs.js:477:25)
    at Proxy.anonymousFunction (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\web3-core-method\dist\web3-core-method.cjs.js:228:25)
    at Context.beforeEach (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\test\Inbox.test.js:9:14)
    at callFn (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\mocha\lib\runnable.js:372:21)
    at Hook.Runnable.run (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\mocha\lib\runnable.js:364:7)
    at next (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\mocha\lib\runner.js:317:10)
    at Immediate.<anonymous> (C:\Users\bsimperc\Desktop\SCOMP\blockchain-projects\Inbox\node_modules\mocha\lib\runner.js:347:5)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    √ deploys a contract


  1 passing (27ms)
我非常感谢任何帮助,因为这是一个实习项目,这是我第一次在区块链环境中工作

PS:这里的建议或建议都不起作用: -
-

我也面临同样的问题,我通过将我的mocha、ganache cli、solc和web3设置为以下版本来解决它

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ganache-cli": "^6.0.3",
    "mocha": "^4.0.1",
    "solc": "^0.4.19",
    "web3": "^1.0.0-beta.37"
  }
}

我完成了同样的课程。以下是我在完成收件箱教程后的个人信息。看看是否有帮助。我还在我的项目中使用了你的
package.json
Index.test.js
,但无法重现错误。它成功了!非常感谢,我想是摩卡咖啡的版本。你知道为什么会这样吗?又来了
{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ganache-cli": "^6.0.3",
    "mocha": "^4.0.1",
    "solc": "^0.4.19",
    "web3": "^1.0.0-beta.37"
  }
}