TypeError: Class extends value undefined is not a constructor or null
Error while importing into React project
import HTMLtoDOCX from 'html-to-docx';
const downloadDocument = async () => {
await saveDocument.mutate();
const finalHtml = `<!DOCTYPE html><html><body>hello</body></html>`;
const blob = await HTMLtoDOCX(finalHtml, null, {
table: { row: { cantSplit: true } },
footer: true,
pageNumber: true,
});
saveAs(blob, `doc.docx`);
};
Well, do u solved the problem?
Same issue here.
I also ran into this. Has anyone found a solution?
Same issue on my side. I am using Vue 3.
I encountered same problem with Vite + Vue3.
It seems that this package depends on xmlbuilder2.
The error is thrown here: https://github.com/oozcitak/xmlbuilder2/blob/master/src/builder/XMLBuilderCBImpl.ts
export class XMLBuilderCBImpl extends EventEmitter implements XMLBuilderCB
I'm not really sure what went wrong in the middle, but I eventually solved the problem with this vite plugin(vite-plugin-node-stdlib-browser), there should be a better solutionš„².
My solution:
-
Install package
pnpm i -D vite-plugin-node-stdlib-browser -
Enable plugin in
vite.config.tsimport nodePolyfills from 'vite-plugin-node-stdlib-browser'; export default defineConfig({ plugins: [ nodePolyfills() ] }); -
Rerun the project