Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

this.removeAllListeners is not a function

devmanzur opened this issue · comments

image

image

here is my function

async function parseXML(xmlContent: string): Promise<{ [key: string]: string }[]> {
  const parser = new xml2js.Parser({ explicitArray: true });
  const parsedData = await parser.parseStringPromise(xmlContent);

  const rowData = parsedData.DATAPACKET.ROWDATA[0].ROW;
  const rowsKeyValue: { [key: string]: string }[] = [];

  rowData.forEach((row: any) => {
    if (row != undefined) {
      const attributes: { [key: string]: string } = {};
      for (const key in row.$) {
        attributes[key] = row.$[key];
      }
      rowsKeyValue.push(attributes);
    }
  });

  return rowsKeyValue;
}

What was the fix?

@devmanzur @jasonhutton-sd Any updates? I got this error too and a little confused

Solution is here:

#88 (comment)

If it helps, this error appeared after I upgraded my project from vite 3.2.7 to vite 5.0.2.

npm i events as per @kontinuity 's link solved it.

commented

If it helps, this error appeared after I upgraded my project from vite 3.2.7 to vite 5.0.2.

npm i events as per @kontinuity 's link solved it.

thats worked for me, tks