DOMParser is not defined at defaultParseHtml

3 replies
Last updated: Dec 3, 2020
Hi again! Ive been trying to use
and i keep getting this error:
ReferenceError: DOMParser is not defined
    at defaultParseHtml (***/studio/node_modules/@sanity/block-tools/lib/HtmlDeserializer/helpers.js:173:35)
Happens on my own code as well as the example code provided in the packages readme, here: I am running the script through
sanity exec
Im puzzled
Dec 3, 2020, 12:16 PM
The HTML-deserialization is done by default by the browser's native DOMParser. On the server side you can give the function 
 that parses the html into a DOMParser compatible model / API.
Dec 3, 2020, 12:18 PM
if you're running it on the server, you need to npm/yarn install some DOM parser like jsdom and use that
Dec 3, 2020, 12:19 PM
That makes complete sense! And you just got rid of my error - thanks a ton! 🍻
Dec 3, 2020, 12:20 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?