11

I got the following errors while trying to deploy my smart contract:

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] });

as suggested in the other thread but it didn't work. My github repository:

https://github.com/damianjnc/lottery

I did npm install --save [email protected] but now got that error:

users-Air: lottery user$ node deploy.js

Attempting to deploy from account 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:lottery user$

4 Answers 4

16

Try installing @truffle/hdwallet-provider like this in the console (same location from where you're deploying):

npm install @truffle/hdwallet-provider

Good Luck!

Edit 2020-06-17: As of 2019-08-22, the package [email protected] has been deprecated and renamed to @truffle/hdwallet-provider. (Source of reference).

2
  • It helped but now I got that errors: 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!(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.
    – Damian
    Commented Nov 19, 2018 at 9:57
  • This is when you're txn is not mined within 50 blocks on Ethereum Blockchain. You can refer to my answer here: [ethereum.stackexchange.com/questions/62349/…. I've found an alternative solution for this problem. Give it a try!
    – itsHarshad
    Commented Nov 19, 2018 at 11:25
3

UPDATE:

truffle-hd-wallet provider has been depreacted: https://www.npmjs.com/package/truffle-hdwallet-provider

Instead use @truffle/hdwallet-provider: https://www.npmjs.com/package/@truffle/hdwallet-provider

After this @truffle/hdwallet-provider will be successfully installed - then reference in required file as follows:

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

I had this problem. What worked was replacing the "truffle-hdwallet-provider" in the require method argument at here: const HDWalletProvider = require('truffle-hdwallet-provider');

with @truffle/hdwallet-provider

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

and truffle compile finally worked.

But make sure you install it first: run this first:

$ npm install @truffle/hdwallet-provider

1

use this as dependancies.

  "dependencies": {
    "solidity-coverage": "^0.5.4",
    "solium": "^1.1.7",
    "truffle": "^4.1.13",
    "web3": "^1.0.0-beta.35",
    "coveralls": "^3.0.2",
    "ethereumjs-wallet": "0.6.2",
    "truffle-hdwallet-provider": "0.0.6",
    "ganache-cli": "^6.1.8"
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.