Hi all,
I’m having trouble using this library: https://www.npmjs.com/package/ipa-parser
I’m trying to transfer the beginnings of a project that uses this library to an Observable notebook, and had it set up locally with node before. My understanding of how requiring libraries work isn’t great, but I have tried a couple different ways, which all lead to the error “Pe: unable to load module”.
I obviously tried ‘require(“ipa-parser”)’, I also tried to load various js files directly from Github or via jsdelivr, but no luck so far.
Is it possible to use this library on Observable and does anybody know how?
Thanks in advance for the help!
Sarah
Unfortunately I don’t think you’ll be able to get ipa-parser to work in the browser: The package uses (among other things) node’s fs
module to access the filesystem.
I’d recommend to looking for alternative libraries that are designed to work client-side.
Hi Sarah!
Sure thing - ipa-parser doesn’t work off the bat, but it didn’t need much modification: here’s a working notebook to start with: https://observablehq.com/@tmcw/using-ipa-parser
The key line to include is:
ipaParser = require("https://bundle.run/@tmcw/ipa-parser@1.0.2-alpha.0")
The details are: ipa-parser did use some things that only work in Node (filesystem access, specifically), but it didn’t have very good reason to. I rewrote those tiny sections (there’s now a PR to the GitHub project), and those changes pushed it enough to get it working with bundle.run. Usually I recommend the module require debugger in cases like this one, but ipa-parse didn’t work with any of the methods initially.
Hope that helps!
-Tom
Hi Tom,
thank you so much for your help, all working now Will keep an eye on the pull request to and switch to that if it goes through.
Sarah
Just in case anyone else wants to use this in the future: Tom’s pull request was accepted by the author and the following works now:
ipaParser = require(‘https://bundle.run/ipa-parser@1.0.3’)