Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Small issues getting up and running with js-ipfs #93

Closed
upfs opened this issue Mar 21, 2016 · 20 comments
Closed

Small issues getting up and running with js-ipfs #93

upfs opened this issue Mar 21, 2016 · 20 comments
Assignees
Labels
kind/support A question or request for support

Comments

@upfs
Copy link

upfs commented Mar 21, 2016

I want to get up on speed with js-ipfs and ran into a few small issues.

package.json

reads "main": "src/index.js" I changed it locally to "main": "src/ipfs-core/index.js" to be able to follow the README usage:

var IPFS = require('ipfs')

var node = new IPFS()

otherwise yields error: ipfs module not found

missing dependency

Should this be added to package.json?
'fs-blob-store'

jsipfs daemon

Initializing daemon... error listen EAFNOSUPPORT :::4001

if run a second time

Initializing daemon... This repo is currently being used by another daemon

Then I rm -r ~/.ipfs and ipfs init using go-ipfs, but can't get jsipf daemon working because of the EAFNOSUPPORT error

I want to run js-ipfs daemon in the browser, but can't even get it to work in node. Is it usable to a degree even if just for basic operations like fetching objects? I tried browserify but get all sort of dependency issues like:

Error: Cannot find module 'buffer!./pb/crypto.proto'

That I'm not sure how to resolve.

Thanks for any pointers on how to get js-ipfs daemon up and running, ideally in the browser!

@daviddias
Copy link
Member

reads "main": "src/index.js" I changed it locally to "main": "src/ipfs-core/index.js" to be able to follow the README usage:

Good catch!

Should this be added to package.json? 'fs-blob-store'

Could you confirm which Node.js and npm versions you are using?

jsipfs daemon

Which go-ipfs version did you use it for init? jsipfs is compatible with the repo version 3, which is generated by go-ipfs 0.4.0. You can check your repo version with:

> cat ~/.ipfs/version
3

I want to run js-ipfs daemon in the browser, but can't even get it to work in node. Is it usable to a degree even if just for basic operations like fetching objects? I tried browserify but get all sort of dependency issues like:

Currently, you have to use webpack, but we are working on a solution(notes) to make it work with any kind of bundler by exposing a es5 compatible version that has already all the shims you need.

@daviddias daviddias added the kind/support A question or request for support label Mar 22, 2016
@upfs
Copy link
Author

upfs commented Mar 22, 2016

Thank you for the detailed information, I hope this will be useful to more devs interested to get started with ipfs.

I'm trying to do exactly this: https://github.com/ipfs/ipfs.js/blob/master/README.md

Is that already possible?

Should this be added to package.json? 'fs-blob-store'
Could you confirm which Node.js and npm versions you are using?

node v5.8.0
npm 3.8.0

I installed js-ipfs v0.4.4 in a new directory, running ./node_modules/.bin/jsipfs I'm missing 'fs-blob-store'

Which go-ipfs version did you use it for init? jsipfs is compatible with the repo version 3, which is generated by go-ipfs 0.4.0. You can check your repo version with:

I had repo v 2, rm ~/.ipfs and compiled go-ipfs v0.4.0 and ipfs init now I have repo version 3.

I have the same issues:

Initializing daemon... error listen EAFNOSUPPORT :::4001

if run a second time

Initializing daemon... This repo is currently being used by another daemon

Currently, you have to use webpack, but we are working on a solution(notes) to make it work with any kind of bundler by exposing a es5 compatible version that has already all the shims you need.

I tried browserify because it was mentioned in js-ipfs-api, using webpack now but the bundle throws an error, more below. I want to download an object using js-ipfs in the browser. This is my

main.js

var IPFS = require('ipfs')

var ipfs = new IPFS()
var mh = "QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"

ipfs.load(() => {
    ipfs.object.get(mh, (err, obj) => {
        console.log(err)
        console.log(obj)
    })
})

Is this code the correct way to do it? If I run node main.js I get the error:


{ [Error: ENOENT: no such file or directory, open '/home/user/.ipfs/blocks/QmPZ9gcC/QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB.data']                                    
  errno: -2,                                                                                                                                                                 
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/user/.ipfs/blocks/QmPZ9gcC/QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB.data' }
undefined

This is my webpack.config.js inspired from the js-ipfs karma.conf.js

webpack.config.js

module.exports = {
    entry: "./main.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },

    resolve: {
        extensions: ['', '.js', '.json']
    },
    externals: {
        fs: '{}',
        'node-forge': 'forge'
    },
    node: {
        Buffer: true
    },
    module: {
        loaders: [{
            test: /\.json$/,
            loader: 'json'
        }]
    }
};

index.html

<html>
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script type="text/javascript" src="bundle.js" charset="utf-8"></script>
    </body>
</html>

Opening index.html in chromium throws the error

bundle.js:32525 Uncaught ReferenceError: forge is not defined

But forge is installed (in node_modules), do I need to

var nodeForgePath = path.resolve(__dirname, 'node_modules/peer-id/deps/forge.bundle.js')

Do I need to launch a daemon before running main.js or does ipfs.load() suffice?

Thanks again for your help and developing this awesome protocoll!

@upfs
Copy link
Author

upfs commented Apr 5, 2016

@diasdavid I know you've been quite busy, just a little bump here to see if you can help me get this working, much appreciated!

@RichardLitt
Copy link
Member

@diasdavid note note.

@upfs thanks for the ping; sorry, we've been really busy the past few days. I'll make sure @diasdavid gets to this. :)

@upfs
Copy link
Author

upfs commented Apr 5, 2016

Awesome, thank you so much! I saw all the great progress you've accomplished over the past few days!!

@daviddias
Copy link
Member

@upfs sorry for the delay in getting back to you. I'm taking just a bit more time because we actually hit the issues you are having some many times, that we decided to clean our assets pipeline so that users can require our modules without having to go through all the config steps. News soon ™ :)

@upfs
Copy link
Author

upfs commented Apr 8, 2016

👍 thanks! looking forward to getting going with js-ipfs

@daviddias
Copy link
Member

@upfs sorry for the lack of news here. Getting it ready for prime time has been taking a bit more than I initially expected, since we have a lot of dependencies in the project and they all need to be updated.

Is this currently blocking you? What is your timeline? Again, apologies for the wait

@upfs
Copy link
Author

upfs commented Apr 14, 2016

@diasdavid no worries, I appreciate the effort. I was more wondering if it is already supposed to work and I'm doing it wrong or if it's not working yet at all. I'm happy to help where I can, if you can identify an introductory issue for me I'd be happy to tackle it ..

@daviddias
Copy link
Member

Thank you for understanding :)

Have you read the entry on the Captain.log? It lists several issues you can help on :)

#30 (comment)

@upfs
Copy link
Author

upfs commented Apr 14, 2016

So since @vijayee is actively working #127 and you're looking for a #128 example it means that js-ipfs is already working? Or is it? I'm confused :-)

@daviddias
Copy link
Member

@upfs apologies for taking so long, but good news here! With the new version (0.4.6) You should be able to require js-ipfs and do not need to do any magic when it comes to webpack shims now :) Hope this makes the process way less cumbersome

//cc @dignifiedquire

@vijayee
Copy link

vijayee commented Apr 22, 2016

Sweet! @diasdavid now for senselessly modular abuse of power

@daviddias
Copy link
Member

@upfs how are your experiments with js-ipfs? :D

@upfs
Copy link
Author

upfs commented May 9, 2016

Haven't tried anything yet, is there an easy getting started guide now? :-)

@daviddias
Copy link
Member

@haadcode has integrated js-ipfs into orbit. @haadcode wanna share some tips there? Agree that we need guides :)

@daviddias
Copy link
Member

@upfs how are your experiments?

@daviddias
Copy link
Member

Hey @upfs how has it been? Have you tried this again?

@upfs
Copy link
Author

upfs commented Oct 30, 2016

@diasdavid sorry for droppping of the earth like this, we were really hot about js-ipfs and since it wasn't quite ready we somewhat moved on, I'll carve out some time soon and give it another whirl, thanks for being on top of this. Is there an easy getting started guide now so I don't need to dig through the sources? :-)

@daviddias
Copy link
Member

hi @upfs you can check https://github.com/ipfs/js-ipfs#ipfs-core-examples-use-ipfs-as-a-module and the example made by @SidHarder too at #576

Closing this one, should be easier now with version 0.18.0. Closing this one, let us know if you find any other hurdle :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

4 participants