0

I am trying to build a Next.js web application in which the browser is an IPFS node. When I am to make the IPFS node, I get this error:

enter image description here

This is the code where I make the IPFS instance:

import * as IPFSCORE from 'ipfs-core';

const IPFS = (() => {
  let IPFSInstance = undefined;

  const createInstance = async () => {
    return await IPFSCORE.create();
  }

  return {
    getInstance: async () => {
      if (!IPFSInstance) IPFSInstance = await createInstance();
      return IPFSInstance;
    }
  }
})();

export default IPFS;

Here is a little more background: I experimented with IPFS on Node.js first. There I got this repo.lock error when I saved my app and then it refreshed (with nodemon). So I thought that making a singleton kind of code in order to create the IPFS instance only once will do the job, and it did. But at the same time, when working locally with Node.js, the repo.lock file was saved on my machine, and when I got the error (prior to making the singleton), I just deleted the file. When I switched to Next.js, I can't find the repo.lock file, like it's not on my machine. Where is the file? Or how can I get rid of this error? Or should I take another approach in order to create the IPFS instance only once?

  • Did you ever figure this out? same issue on our end – Nerdi.org Jan 02 '23 at 22:48
  • Not really. I ditched the browser and went for a desktop app with Electron, and I put the initialization of the IPFS node on Node.js. In Electron, the Node.js doesn't reload, so it's fine. – Timotei Oros Jan 04 '23 at 09:42

0 Answers0