Getting error while using the libp2p-mplex muxer in my nodejs application

I’m following the getting started tutorial and whenever I require the libp2p-mplex I get this error in the console. How can I fix this?

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No “exports” main defined in /home/hazesoft/practice/libp2p/basic/node_modules/libp2p-mplex/package.json

Node version is v16.14.0


I am also new and I got the same problems, I think is because mplex is now esm module only.

I had some troubles put the mplex lib working, I also open a issue here Version 1.0.0 and 1.0.1 I think they have a bug · Issue #161 · libp2p/js-libp2p-mplex · GitHub I hope it helps.

First I changed the file from .js to mjs and changed everything to imports, and then I got the error that I reported on the issue so I installed the version v0.10.7 , I guess if you use libp2p-mplex version v0.10.7 the examples will work and you don’t need to change the code to imports.

I hope this helps.

1 Like