How to enable dht routing in node IPFS ? I'm trying to findprovs of CIDs

“How to enable dht routing in node IPFS ? I’m trying to findprovs of CIDs”
I got error “dht not enabled”

const IPFS = require('ipfs-core')

async function run()  {
  const ipfs = await IPFS.create({Routing: 'dht' }) // I should enter dht here?
  const { cid } = await ipfs.add('Hello world')

  console.log(cid)
  // QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve

  const providers = ipfs.dht.findProvs('QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve')

  for await (const provider of providers) {
    console.log(provider.id.toString())
  }

}

run()

node_modules/ipfs-core/src/components/dht.js:216
throw new NotEnabledError(‘dht not enabled’)

hello,

i’m not core-api expert but do you check that : DHT : findprovs

regards

Of course. I’m using ipfs.dht.findProvs like in the API example. But I got the error:
node_modules/ipfs-core/src/components/dht.js:216
throw new NotEnabledError(‘dht not enabled’)

So I’m asking how to enable dht routing?

const ipfs = await IPFS.create({
	libp2p: {
		config: {
			dht: {
				enabled: true
			}
		}
	}
});

Good luck! :slight_smile: