I setup a minimal test to convert HTML content from our old data sources to Prismic, but I can't get it to work :
import { htmlAsRichText } from '@prismicio/migrate'
const html = '<p>Hello</p>'
const richText = htmlAsRichText(html)
console.log(richText)
When running this with nodejs 22.14.0, this error is thrown :
Error: Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither
at addPreset (node_modules/unified/lib/index.js:1110:15)
at Function.use (node_modules/unified/lib/index.js:1076:9)
at htmlAsRichText (node_modules/@prismicio/src/htmlAsRichText.ts:112:4)
at <anonymous> (import-test.ts:6:18)
The error you’re seeing is related to the unified library, which @prismicio/migrate depends on for parsing HTML. Here's some possible causes to look at:
Missing rehype Dependencies
The unified processor expects certain rehype plugins to be present. Try installing them manually:
npm install rehype-parse rehype-stringify
Use esm Imports
Since you're using Node.js 22, try using import instead of require, and make sure your package.json has:
"type": "module"
Upgrade @prismicio/migrate
Check if you're using the latest version of @prismicio/migrate with:
npm outdated @prismicio/migrate
Then update if needed:
npm update @prismicio/migrate
Let me know how that goes, and if these help at all!