Error: Cannot find module 'truffle-hdwallet-provider` when deploying to a public network

(reply to: Deploy contracts to a public network)

When try to migrate $ npx truffle migrate --network mainnet!
Error: Cannot find module 'truffle-hdwallet-provider @abcoathup
Untitled|685x500

1 Like

Hi @Rahaman,

Can you check your package.json to see that you have @truffle/hdwallet-provider installed?

Otherwise please install:

$ npm install --save-dev @truffle/hdwallet-provider 

Thanks @abcoathup
I have tried and this time a different Error “unexpected token” coming please see attached image…

1 Like

Hi @Rahaman,

It looks like your truffle-config.js is malformed and you have a curly bracket in the wrong place.

Not understand, sorry. Please explain me.@abcoathup

I think truffle/hdwallet-provider is not installing on my PC.@abcoathup

1 Like

Hi @Rahaman,

Are you able to upgrade to Windows 10? You could then run Windows Subsystem for Linux. Solidity Smart Contract development on Windows

Developing smart contracts on native Windows can be problematic as not all projects work/test on Windows. In 2017/18 I was developing on Windows 7 and used to run into problems regularly. I have a much easier time using WSL.

You could try creating an issue for @truffle/hdwallet-provider installation on Windows.

1 Like

Hi @abcoathup
I was installed few month ago, but my PC was run very slowly, then i was change. can i install others OS to good for deploying.

1 Like

Hi @Rahaman,

Linux would be the best thing to use.

1 Like

Hi :slight_smile:

I ran into the same issue after I switched into a project that I’ve written and published exact a year ago. I wanted to execute some methods on a smart contract and got the same issue.

In my case, I had to change the require-statement for hdwallet-truffle-provider as it was still the “old” name instead of the current one:

I changed:

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

into

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

and everything is running again as expected :slight_smile:

Hope this helps

Best, itinance

2 Likes