Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 596 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') #651

Open damianof opened 1 year ago

damianof commented 1 year ago

Getting this with version 0.4.23:

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at sax.js:222:46 at node_modules/sax/lib/sax.js (sax.js:1565:1) at require (chunk-UNANNA3Z.js?v=1c06db08:38:50) at Object. (parser.js:9:9) at node_modules/xml2js/lib/parser.js (parser.js:381:4) at __require (chunk-UNANNA3Z.js?v=1c06db08:38:50) at Object. (xml2js.js:12:12) at node_modules/xml2js/lib/xml2js.js (xml2js.js:39:4) at require (chunk-UNANNA3Z.js?v=1c06db08:38:50) at dep:xml2js:1:16

SAXStream.prototype = Object.create(Stream.prototype, { // Stream seems to be undefined constructor: { value: SAXStream } })

mathieuguyot commented 1 year ago

Hi I faced the same issue, if you are using vite, please take a look at https://github.com/vitejs/vite/issues/7555 what worked for me was to add resolve: { alias: { stream: "stream-browserify" } } inside the defineConfig of your vite.config.ts

or simply add stream dependency

BugKiller-tech commented 11 months ago

@mathieuguyot Hi, Should I install the npm package stream-browserify?