🏠 back to Observable

Cannot load xml2js.js and it's killing me

I’m trying to require xml2js.js (https://www.npmjs.com/package/xml2js) and I cannot get it to work.

What’s crazy is it used to work?

I’ve tried the module require debugger and it says no go on any options. I’ve tried requiring the js from unpkg and still nada.

The error is:
converter = vt: invalid module

Anyone have any ideas? I’m at a loss.

It looks like xml2js is only published in CommonJS intended for Node, so you’ll need something like bundle.run or wzrd.in to convert it into a browser-friendly format. We normally recommend bundle.run, but it currently appears to be down and serving 503 errors. Fortunately, wzrd.in does currently appear to be working:

https://wzrd.in/standalone/xml2js@latest

So, you can say:

xml2js = require("https://wzrd.in/standalone/xml2js@0.4")

If you want your notebook to work even if bundle.run or wzrd.in is down (as these services are generally much less reliable than our normal npm-backed CDN of choice, jsDelivr), you can attach the bundled library as a file to your notebook and load it that way. For example:

2 Likes

THANK YOU! Yes, I was using bundle before, so should have put that together. Thanks again, wzrd is working great.