[Vite] Build failed: No matching export
tymmesyde opened this issue · comments
What version of this package are you using?
2.1.15
What operating system, Node.js, and npm version?
Node: 16.20.0 | pnpm: 8.6.1
What happened?
Using VITE v4.4.7
Build fail with these errors:
✘ [ERROR] No matching export in "(disabled):node_modules/.pnpm/create-torrent@6.0.12/node_modules/create-torrent/get-files.js" for import "default"
node_modules/.pnpm/create-torrent@6.0.12/node_modules/create-torrent/index.js:14:7:
14 │ import getFiles from './get-files.js' // browser exclude
╵ ~~~~~~~~
✘ [ERROR] No matching export in "(disabled):node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/lib/client/http-tracker.js" for import "default"
node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/client.js:10:7:
10 │ import HTTPTracker from './lib/client/http-tracker.js' // empty object in browser
╵ ~~~~~~~~~~~
✘ [ERROR] No matching export in "(disabled):node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/lib/client/udp-tracker.js" for import "default"
node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/client.js:11:7:
11 │ import UDPTracker from './lib/client/udp-tracker.js' // empty object in browser
╵ ~~~~~~~~~~
✘ [ERROR] No matching export in "(disabled):node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/server.js" for import "default"
node_modules/.pnpm/bittorrent-tracker@10.0.10/node_modules/bittorrent-tracker/index.js:3:7:
3 │ import Server from './server.js'
╵ ~~~~~~
✘ [ERROR] No matching export in "(disabled):node_modules/.pnpm/webtorrent@2.1.15/node_modules/webtorrent/lib/conn-pool.js" for import "default"
node_modules/.pnpm/webtorrent@2.1.15/node_modules/webtorrent/index.js:16:7:
16 │ import ConnPool from './lib/conn-pool.js' // browser exclude
Not sure what is going on here
What did you expect to happen?
To build successfully with vite
Are you willing to submit a pull request to fix this bug?
No
use module alias field, vite is overall very bad at this which is why webpack is recommended,
use module alias field, vite is overall very bad at this which is why webpack is recommended,
@ThaUnknown Can you explain what do you mean by that ?
Same error here, do I add browser field like this? Still result in same error:
"browser": {
"./get-files.js": false,
"./lib/client/http-tracker.js": false,
"./lib/client/udp-tracker.js": false,
"./lib/conn-pool.js": false
}
@zaqxs123456
I did this in my vite.config
and it worked:
resolve: {
alias: {
'webtorrent': fileURLToPath(new URL('./node_modules/webtorrent/dist/webtorrent.min.js', import.meta.url)),
},
},
@tymmesyde Thank you very much! It worked!