TypeError: Cannot read properties of undefined (reading 'length')

We always get this error, when we run below,

    type: 'paragraph',
    content: {
      text: "Sample para text",
      spans: [],


"prismic-dom": "^2.2.7"

Hi @aniruddha.shevle ,

I'm not sure what you're trying to do here. Are you trying to pass raw JSON like this to the dom package? Why not API IDs?


@Phil : I'm actually trying to migrate Prismic content to another platform and for that after exporting the Prismic document, I need its respective HTML format to migrate the documents.

Can you suggest me a better way for this?

The only way to get the respective HTML would be to scrap the final output on your website page. You could use a scraper for this task. Alternatively, you could use a script that processes the JSON and feeds it through the dom like above, but it can't be raw JSON; it has to be an API ID.

@Phil : Don't we have any automated way to resolve this? Many documents need to be migrated.

No unfortunately not. But you can output it as HTML like so:

@Phil : I'm exactly doing as above example and gives me the mentioned error.
Also, what do you mean by below?

but it can't be raw JSON; it has to be an API ID

The API ID is the reference to the field in the JSON rather than the JSON itself, like when you hit the API endpoint.