Js-ipfs: jsipfs : how to use exist node in node.js

Created on 20 Aug 2017  路  6Comments  路  Source: ipfs/js-ipfs

  • Version: 0.25.1
  • Platform: mac osX
  • Subsystem:

Type: question

Severity: medium

Description:

when I run node.js , the function
(const node = new IPFS({
init: true,
start: true,
repo: repoPath)}
)
will produce the new node again, hence I can't change the config in this node, because I don't know how to use the node I had produced.

Steps to reproduce the error:

All 6 comments

Hi @kappabooom, you are telling the node to "init the repo" again with the option "init: true". You can get your issue solved and simplified by just having:

const node = new IPFS({
  repo: repoPath
})

@diasdavid Thanks for your answer~ but I got some troubles on use 'repoPath' , it will appear error " Error: repo already exists", when I run the code:

const repoPath = 'test';
const node = new IPFS({ repo: repoPath, });

Right. My bad, that is because it defaults to init the repo. Do:

const node = new IPFS({
  init: false,
  repo: repoPath
})

On the second time

@diasdavid Yes, I solved this problem. Thank you very much!!!

wooot @kappabooom :D

Is there a way to tell it to init the repo if it hasn't already been inited, and not otherwise ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lidel picture lidel  路  3Comments

beingmohit picture beingmohit  路  3Comments

lifeBCE picture lifeBCE  路  3Comments

npfoss picture npfoss  路  3Comments

daviddias picture daviddias  路  3Comments