"Web3ProviderEngine does not support synchronous requests"

"Web3ProviderEngine does not support synchronous requests"

我想用 provider.When 配置我的 truffle-config.js 我 运行 命令 "truffle migrate --network ropsten",它出现 Error as title show

Error: Web3ProviderEngine does not support synchronous requests.

错误详情告诉

at Object.run (C:\Users\Bruce\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)

我对此一无所知。我找文件 "C:\Users\Bruce\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1",但是找不到"build/"下的路径webpack。是不是出什么问题了?我使用全局安装 truffle,它 运行 与默认网络 ganache 配合得很好。

ropsten: {
      provider: () => new HDWalletProvider(
        privateKeys.split(','),
        `https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`
      ),
      network_id: 3,       // Ropsten's id, mainnet is 1
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      gasPrice: 2500000000, //2.5 gwei
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },

我的HDWalletProvider依赖版本:

 "dependencies": {
    "chai": "^4.2.0",
    "chai-as-promised": "^7.1.1",
    "dotenv": "^8.1.0",
    "eslint": "^6.4.0",
    "openzeppelin-solidity": "^2.3.0",
    "truffle-hdwallet-provider": "^1.0.17",
    "truffle-hdwallet-provider-privkey": "^0.3.0",
    "web3": "^1.2.1"
  },

以及迁移:

1_initial_migration.js

const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

2_deploy_contract.js

const Token = artifacts.require("TokenInstance");
const DeleToken = artifacts.require("DelegateToken")
module.exports = async function(deployer) {

  deployer.deploy(Token);
  deployer.deploy(DeleToken);

};

就是编译不成功。但是我用ganache的默认网络是可以的!

您仍在使用已弃用的旧存储库。

你应该改用 truffle monorepo

npm install @truffle/hdwallet-provider

并替换

const HDWalletProvider = require("@truffle/hdwallet-provider");

你也不需要使用 truffle-hdwallet-provider-privkey