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

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in package.json #179

Open
fabriziogianni7 opened this issue Sep 16, 2022 · 2 comments

Comments

@fabriziogianni7
Copy link

Hi,
I'm using node v16,
following the 1sts steps of the tutorial
got this error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/fabri/keyko/orbit/node_modules/ipfs/package.json

my files:
newpieceplease.js

class NewPiecePlease {
  constructor (Ipfs, OrbitDB) {
    this.OrbitDB = OrbitDB
    this.Ipfs = Ipfs
  }

  async create() {
    this.node = await this.Ipfs.create({
      preload: { enabled: false },
      repo: './ipfs',
      EXPERIMENTAL: { pubsub: true },
      config: {
        Bootstrap: [],
        Addresses: { Swarm: [] }
      }
    })

    this._init()
  }

  async _init () {
    this.orbitdb = await this.OrbitDB.createInstance(this.node)
    this.defaultOptions = { accessController: {
      write: [this.orbitdb.identity.id]
      }
    }
    if(this.onready) this.onready();
  }
}

try {
    // console.log('in try')
    const Ipfs = require('ipfs')
    const OrbitDB = require('orbit-db')

    module.exports = exports = new NewPiecePlease(Ipfs, OrbitDB)
} catch (e) {
    console.log(e)
    // window.NPP = new NewPiecePlease(window.Ipfs, window.OrbitDB)
}

main.js

const NPP = require('./newpieceplease') 

const main = async () => {
console.log(NPP)

}

main()
@fabriziogianni7
Copy link
Author

fabriziogianni7 commented Sep 16, 2022

referencing this issue from ipfs repo -- > ipfs/js-ipfs#4139

changing my file this way:

newpieceplease_v2

 // i just need it in nodejs so don't care about browser part
export default class NewPiecePlease {
  constructor(Ipfs, OrbitDB) {
    this.OrbitDB = OrbitDB
    this.Ipfs = Ipfs
  }

  async create() {
    this.node = await this.Ipfs.create({
      preload: { enabled: false },
      repo: './ipfs',
      EXPERIMENTAL: { pubsub: true },
      config: {
        Bootstrap: [],
        Addresses: { Swarm: [] }
      }
    })

    this._init()
  }

  async _init() {
    this.orbitdb = await this.OrbitDB.createInstance(this.node)
    this.defaultOptions = {
      accessController: {
        write: [this.orbitdb.identity.id]
      }
    }
    if (this.onready) this.onready();
  }
}

main.js:

iimport NewPiecePlease from './newpieceplease_v2.js'
import * as Ipfs from 'ipfs'
import OrbitDB from 'orbit-db'


const main = async () => {
    try {
        const NPP = new NewPiecePlease(Ipfs, OrbitDB)
        await NPP.create()

        NPP.onready = () => console.log(NPP.orbitdb.identity.id)

    } catch (error) {
        console.log(error)
    }
}

main()

@fabriziogianni7
Copy link
Author

let me know any thought
thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant