The turndown
library has a default export. Therefore to import it you’d want to do:
import * as Turndown from "turndown";
You’d then be able to construct it as follows:
const turndown = new Turndown.default();
(this differs from the Node.js usage seen on GitHub as we do not support CommonJS)
However, the turndown
library also relies on the existence of a global document
object. Functions are run in a base V8 environment (“pure” JavaScript), so browser and Node.js APIs are generally not available (with the exception of setTimeout
). You’ll need to find another library that can convert HTML to markdown using “pure” JavaScript.
There is a similar, widely-used library called node-html-markdown
which does not rely on browser APIs. This should work.