Closed
Description
The Error
I get the following runtime error in a CJS node.js (v22.12.0) micro service:
TypeError: A dynamic import callback was invoked without --experimental-vm-modules
at importModuleDynamicallyCallback (node:internal/modules/esm/utils:264:11)
at pdf2png (.../node_modules/.pnpm/pdf-visual-diff@0.14.0/node_modules/pdf-visual-diff/src/pdf2png/pdf2png.ts:74:27)
at compareWithSnapshot (.../node_modules/.pnpm/pdf-visual-diff@0.14.0/node_modules/pdf-visual-diff/src/compare-pdf-to-snapshot.ts:223:31)
at comparePdfToSnapshot (.../node_modules/.pnpm/pdf-visual-diff@0.14.0/node_modules/pdf-visual-diff/src/compare-pdf-to-snapshot.ts:150:12)
at comparePdfs (.../node/document-generation-service/src/testutils/compare-pdfs.ts:14:26)
at generate-registration-pdf.test.ts:56:7
It seems that the function pdf2png in pdf2png.ts does the following dynamic import:
const { getDocument } = await import('pdfjs-dist/legacy/build/pdf.mjs');
According to my understanding dynamic import aren't supported in CJS or how should I use the library in a CJS setup?
Metadata
Metadata
Assignees
Labels
No labels