isaacs / sax-js

A sax style parser for JS
Other
1.09k stars 325 forks source link

Stream : Uncaught TypeError: Cannot read property 'prototype' of undefined #254

Closed 1045922393 closed 11 months ago

1045922393 commented 2 years ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch sax@1.2.4 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/sax/lib/sax.js b/node_modules/sax/lib/sax.js
index 795d607..51d879c 100644
--- a/node_modules/sax/lib/sax.js
+++ b/node_modules/sax/lib/sax.js
@@ -218,7 +218,7 @@
       })
     })
   }
-
+  if(!Stream) Stream = function(){}
   SAXStream.prototype = Object.create(Stream.prototype, {
     constructor: {
       value: SAXStream

This issue body was partially generated by patch-package.

XiaoPiHong commented 1 year ago

I have the same problem.

sjors98 commented 1 year ago

I have this issue as well when using aws-sdk in react-native. However this issue only seems to happen on Android, not on iOS... The patch works for me, but it would be nice if this can be fix in sax-js itself :)

austinGENEreeve commented 1 year ago

I am running into this issue with react native as well. I am seeing the issue on iOS right now. using as a dependancy of azure-sdk-for-js

The answer provided works for now