Truffle
錯誤:找不到模組“truffle-hdwallet-provider”
嘗試部署我的智能合約時出現以下錯誤:
sers-Air:lottery user$ node deploy.js internal/modules/cjs/loader.js:582 throw err; ^ Error: Cannot find module 'truffle-hdwallet-provider' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.Module._load (internal/modules/cjs/loader.js:506:25) at Module.require (internal/modules/cjs/loader.js:636:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (/Users/user/Documents/prod/EthereumCasts/lottery/deploy.js:1:88) at Module._compile (internal/modules/cjs/loader.js:688:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32) at tryModuleLoad (internal/modules/cjs/loader.js:537:12) at Function.Module._load (internal/modules/cjs/loader.js:529:3) users-Air:lottery user$ I also tried to change it to const result = await new web3.eth.Contract(JSON.parse(interface)) .deploy({ data: '0x' + bytecode }) .send({ from: accounts[0] });
正如另一個執行緒中所建議的,但它沒有用。我的 github 倉庫:
https://github.com/damianjnc/lottery
我做
npm install --save truffle-hdwallet-provider@0.0.3
了,但現在得到了那個錯誤:users-Air: 彩票使用者$ node deploy.js
嘗試從帳戶部署
0x14Ca642FA083121605fc860dB0024254D3FaCd61
(node:31456) UnhandledPromiseRejectionWarning: Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined! at /Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-method/src/index.js:375:45 at tryCatcher (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:497:31) at Promise._settlePromise (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:555:18) at Promise._settlePromise0 (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:600:10) at Promise._settlePromises (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:679:18) at Async._drainQueue (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:125:16) at Async._drainQueues (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:135:10) at Immediate.Async.drainQueues (/Users/user/Documents/prod/EthereumCasts/lottery/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:16:14) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) (node:31456) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:31456) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
users-Air:彩票使用者$
嘗試
@truffle/hdwallet-provider
在控制台中像這樣安裝(與您部署的位置相同):npm install @truffle/hdwallet-provider
祝你好運!
***編輯 2020-06-17:*截至 2019-08-22,該軟體包
truffle-hdwallet-provider@1.0.17
已被棄用並重命名為@truffle/hdwallet-provider
. (參考來源)。
更新:
truffle-hd-wallet 提供程序已被棄用: https ://www.npmjs.com/package/truffle-hdwallet-provider
而是使用@truffle/hdwallet-provider: https ://www.npmjs.com/package/@truffle/hdwallet-provider
在此@truffle/hdwallet-provider 將成功安裝之後 - 然後在所需文件中引用如下:
var HDWalletProvider = require("@truffle/hdwallet-provider");