webtorrent / webtorrent

⚡️ Streaming torrent client for the web
https://webtorrent.io
MIT License
29.62k stars 2.72k forks source link

No "exports" main defined in ...\node_modules\create-torrent\package.json #2875

Open TurningTide opened 2 weeks ago

TurningTide commented 2 weeks ago

What version of this package are you using? ^2.5.1. I use it on server with NestJS

What operating system, Node.js, and npm version? Windows 11, Node 20.18/22.8, npm 10.8.

What happened? When i use let client = new WebTorrent(); anywhere in my code, app boot fails with

Uncaught Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\...\node_modules\create-torrent\package.json

This prevents me from using the WebTorrent client, as the whole app crashes.

What did you expect to happen? I expected the WebTorrent client to be created and the app to run successfully, not crash entirely.

Are you willing to submit a pull request to fix this bug? I tried manually setting the exports in create-torrent's package.json, but encountered the same error in another dependency afterward.

SilentBot1 commented 6 days ago

Hey @TurningTide,

This likely relates to how you are bundling WebTorrent, as I've never experienced this issue before when bundling the library.

It would be recommended for you to use import WebTorrent from 'webtorrent/dist/webtorrent.min.js', rather than importing and bundling the package locally due to all the polyfills required to bundle the app.