I'm trying to include web3 & truffle in my chrome extension. In npm, I'm doing it this way:

    const HDWalletProvider = require('truffle-hdwallet-provider');
    const Web3 = require('web3');

But in chrome it's giving this error:

    Uncaught ReferenceError: require is not defined

I know that we can't do it this way in the browser mode. But how to solve this problem? What's the correct way to use truffle & web3js

  • 2
    I believe that the correct syntax for client-side code (i.e., browsers) is import instead of require. So it looks more of a question for Stack Overflow rather than this forum. – goodvibration Oct 31 '19 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.