You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ node src/index.js
node:internal/modules/esm/resolve:303
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ping' is not defined by "exports"in /home/jehaverlack/Documents/Demos/hello-libp2p/node_modules/libp2p/package.json imported from /home/jehaverlack/Documents/Demos/hello-libp2p/src/index.js
at exportsNotFound (node:internal/modules/esm/resolve:303:10)
at packageExportsResolve (node:internal/modules/esm/resolve:650:9)
at packageResolve (node:internal/modules/esm/resolve:836:14)
at moduleResolve (node:internal/modules/esm/resolve:910:20)
at defaultResolve (node:internal/modules/esm/resolve:1130:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v20.11.0
Here is my src/index.js and package.json
src/index.js
importprocessfrom'node:process'import{createLibp2p}from'libp2p'import{tcp}from'@libp2p/tcp'import{noise}from'@chainsafe/libp2p-noise'import{mplex}from'@libp2p/mplex'import{multiaddr}from'multiaddr'import{pingService}from'libp2p/ping'constnode=awaitcreateLibp2p({addresses: {// add a listen address (localhost) to accept TCP connections on a random portlisten: ['/ip4/127.0.0.1/tcp/0']},transports: [tcp()],connectionEncryption: [noise()],streamMuxers: [mplex()],services: {ping: pingService({protocolPrefix: 'ipfs',// default}),},})// start libp2pawaitnode.start()console.log('libp2p has started')// print out listening addressesconsole.log('listening on addresses:')node.getMultiaddrs().forEach((addr)=>{console.log(addr.toString())})// ping peer if received multiaddrif(process.argv.length>=3){constma=multiaddr(process.argv[2])console.log(`pinging remote peer at ${process.argv[2]}`)constlatency=awaitnode.services.ping.ping(ma)console.log(`pinged ${process.argv[2]} in ${latency}ms`)}else{console.log('no remote peer address given, skipping ping')}conststop=async()=>{// stop libp2pawaitnode.stop()console.log('libp2p has stopped')process.exit(0)}process.on('SIGTERM',stop)process.on('SIGINT',stop)
I'm attempting to follow the direction at:
But I keep getting this error:
Here is my src/index.js and package.json
src/index.js
package.json
The text was updated successfully, but these errors were encountered: