2

I am using the Embark framework demo code and trying to include IPFS storage (not deployment) functionalities to the project. I get an error message when I try to execute the following code in the browser

ipfs.catText("QmZYZyvJeW3eXEiRPS61hvyWSwuHWuSdQRjxmvsD2XqBom", 
       function(err, res) {
           if(err || !res) return console.error(err)
           console.log(res);
    })

I have included ipfs-js from a local folder with <script src="js/ipfs.js"></script>

The error is shown in browser console Error: Cannot find module 'fs'

1

fs is node js file system module. You have used a script that was meant for node in the browser.

Instead of using this script, you should follow these instructions on how to include the ipfs api in the browser

  • I don't understand what the difference is between your suggestion and what I have done. As I say I've included the script through a tag. In the instructions it says: Browser friendly Run npm install ipfs-js Or reference dist/ipfs.min.js inside a <script /> to expose the global ipfs – samurai jack Mar 31 '16 at 4:13
  • Yes, but it seems you have included the wrong script. Did you try including the minified script instead of the node module you linked to? – MrChico Mar 31 '16 at 6:07
  • Got it working in the end with the Consensys ipfs wrapper. – samurai jack Mar 31 '16 at 7:47

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.