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

node.on('ready') won't trigger when reinstall ipfs #1015

Closed
EasonWang01 opened this issue Sep 13, 2017 · 6 comments
Closed

node.on('ready') won't trigger when reinstall ipfs #1015

EasonWang01 opened this issue Sep 13, 2017 · 6 comments
Labels
kind/support A question or request for support

Comments

@EasonWang01
Copy link

EasonWang01 commented Sep 13, 2017

  • Version: nodejs 6.11.3 ipfs: lastest
  • Platform: ubuntu 16.04

Because npm issue,so when I install other dependence the ipfs modue been deleted,so I install ipfs again.

But when execute the code below again will not happen anything after reinstall ipfs usingnpm install ipfs or yarn add ipfs.
trying to remove node_module and reinstall but still not works.

but there is a node object for console.log(node)

const IPFS = require('ipfs')
const fs = require('fs');

const node = new IPFS()
node.on('ready', () => {
  node.files.add({
    path: '',
    content: fs.createReadStream('./sample.txt')
  }, (err, result) => {
    if (err) { throw err }

    console.log('\nAdded file:', result[0].path, result[0].hash)
  })
})
@daviddias
Copy link
Member

Are you sure it is the ready event? Add a console log before the node.files.add.

@daviddias daviddias added the kind/support A question or request for support label Sep 13, 2017
@EasonWang01
Copy link
Author

Yes,this code works before #1000

@EasonWang01
Copy link
Author

EasonWang01 commented Sep 13, 2017

Found out the error

Error: can't lock file /home/.jsipfs/repo.lock: has non-zero size
    at fs.stat (/home/node_modules/lock-me/src/unix.js:11:19)
    at FSReqWrap.oncomplete (fs.js:123:15)

@daviddias
Copy link
Member

looks like the lock was left behind. just remove that file :)

@EasonWang01
Copy link
Author

Thanks,do you know which situation will generate this lock file.

@daviddias
Copy link
Member

Glad that worked :)

The lock file is generated every time to start the node. You need to shutdown the node graciously (with .stop) to remove it. If you kill the process, then you have to remove it manually.

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

2 participants