-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No matching export in "browser-external:stream" #5398
Comments
The subtitle library can only be used in nodejs since it uses node's builtin modules. It looks like you're using it in a browser environment. There are ways to polyfill these but it's not encouraged to do so. |
Thanks. So far we were using the subtitle library fine in react thanks to webpack bundling. So I thought vite could also manage to compile it. |
I made some more research, I found that node builtins module are usually browserified in usual bundlers (they use the browserify version of the module if existing). So I export default defineConfig({
resolve: {
alias: {
stream: 'stream-browserify',
},
},
plugins: [
react()
]
}) Now, the bundling is working ! Howerver, when running the webapp, the console return this error :
Here is the line in readable-strean that is responsible for the error : var OurUint8Array = global.Uint8Array || function () {}; Any ideas on the reason why global is not defined ? Shouldn't it be defined by default normally ? Thanks ! |
|
similar problem with ipfs, electron-fetch, ... project is IPFS-CRDT-shared-editing
probably relevant build script in package.json with node-globals.js
|
still getting fixed with // vite.config.js
export default {
resolve: {
alias: {
'node:stream': 'stream-browserify',
},
},
} but now im getting workaround
fails with |
Any updates on this? |
closing as #5398 (comment) is solved by #7006 |
Describe the bug
Explanation of the error
When using vite with a react project including the library subtitle, we have the two following errors :
and
(Full error below)
The error is from the builtin module stream that , for a reason I ignore, is replaced by browser-external:stream.
The problem is similar to this one : aws-amplify/amplify-js#9639
As well as maybe this one : #1979
Error Message
Reproduction
Method 1 : Cloning from my example repo
Method 2 : Install from scratch
Add the following line after the imports in App.tsx :
and then, run vite :
System Info
Validations
The text was updated successfully, but these errors were encountered: