0

Error:-

Uncaught Error: Cannot find module './truffle-contract.min.js' at c (web3.min.js:1) at c (web3.min.js:1) at index.html:27

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="./web3.min.js"></script>
    <script type="text/javascript" src="./truffle-contract.min.js"></script>
    <title>Test For blockchain</title>
</head>
<body>
    <script>    
        var Web3 = require("web3");
        if (typeof web3 !== 'undefined')
        { 
            web3 = new Web3(web3.currentProvider); 
        } 
        else 
        { 
            web3 = new Web3(new Web3.providers.HttpProvider("https://shivansh.blockchain.azure.com:3200/######")); 
        }
        //wb = new Web3(web3);
        //var HelloBlockchain = artifacts.require("HelloBlockchain");
        console.log("test");


        let contract = require('./truffle-contract.min.js')
        let HelloWorld = contract(require('./build/contracts/HelloBlockchain.json'))

        HelloWorld.setProvider(web3);
        HelloWorld.deployed().then(contract => {
        return contract.getMessage()
        }).then(response => {
        console.log(response)
        })
    </script>
</body>
</html>
0

Make sure you have truffle-contract.min.js file in the same location as you are providing in your code i.e.,

src="./truffle-contract.min.js"

  • It is in the correct place. – Hardik Mehta Aug 16 at 19:10
  • Can you show me the directory structure(including this file) of your project? – Prachi Sharma Aug 16 at 19:26
  • I can't since i have deleted the project as it was just for testing making a simple blockchain but I am sure that the minified truffle contract file was in the root folder. – Hardik Mehta Aug 16 at 19:40

Your Answer

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

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