Modular Content Field - dato dump not working


I use a ‘dato.config.js’ file in my project to create JSON files from the CMS data. The content model is called ‘projects’ and in there I have a Modular Content Field called ‘body’.

When running the ‘dato dump’ command I get the following error in the terminal (“Cannot read property ‘nl’ of null”) which seems to be related to the locales.

The config does work for all the other fields (in 2 languages), except for any of the Modular Content Fields. I used the suggested code from this page: but I can’t get it to output the data from ‘body’ inside my JSON files.

Do you have any suggestions? Here’s an example of my code:

module.exports = (dato, root, i18n) => {


  // iterate over all the administrative area languages
  i18n.availableLocales.forEach((locale) => {

    // create a separate folder for each locale`cms/content/projects-${locale}`, (projectsFolder) => {

      // switch to the nth locale
      i18n.withLocale(locale, () => {

        // iterate over the 'Projects' records
        dato.projects.forEach((project) => {

          // create a localized JSON file for each project
          projectsFolder.createPost(`${project.slug}_${locale}.json`, 'json', {
            frontmatter: {
              layout: 'project',
              languages: [`${locale}`],
              slug: project.slug,
              heroImage: project.heroImage.toMap(),
              title: project.title,
              body: project.body.toMap(), // Modular Content Field, not working
              subtitle: project.subtitle,
              organisation: project.organisation,
              relatedTitle: project.relatedTitle,
              ctaTitle: project.ctaTitle

hello @pims, welcome :slight_smile:

I’m sorry for that bug, but I’ve just released a new version of the JS client that should address your use case:

Please try that and let me know if it’s fixed. Thank you for reporting this.

Hi Mat,

Thank you for your reply. I tried again today, but the error was still the same. Should I change something in my dato.config.js file after your update?

hey @pims can you please confirm you are using datocms-client v2.0.10?


I forgot to update my package.json, but the problem is solved with v2.0.10 :+1:

Grazie mille!

1 Like

Excellent!! Thanks for letting me know :wink:

Hi @mat_jack1,

Is it also possible to get a full JSON object with all records in one go, without specifying each data field inside frontmatter?

Example: I can log ‘dato.projects’ inside my terminal to see all the projects, but I don’t know how to save this in a single JSON file using dato.config.js.

Hope to hear from you.

yes @pims have a look at this:

isn’t that what you need?

@mat_jack1 I gave this a try, but it’s not exactly the solution I am looking for. It misses some of the data which I need to have in order to build a static website (with Nuxt / Vue components).

The best solution would be to have a single JSON file with all the projects inside it, which I can use in a Vue component. I would like to collect all this ‘projects’ data and let the Vue component decide how to use this.

It seems that this data is available (dato.projects for example), but is there a way to save this in a file?

I’m not sure what you mean. What data is missing from the dump made in the backup?

And if with dato.projects you can get all of what you need, can’t you write that directly to a JSON file?

I found a solution with node-fs to concat all JSON files inside a folder into one JSON file. I need this file in Vue to loop over the projects in the JSON and create dynamic routing for each project page.

Thanks for reaching out!

1 Like

Hi @mat_jack1,

I still have one question left :upside_down_face: I try to retrieve all the data with this code from the docs:

client.items.all({}, { allPages: true })
  .then((records) => console.log(records))

In this image you can see the result. Example: It says “body:” > “en:” but how can I also get the content from the ID fields (556579, 556580 etc.) inside the same JSON file?

@pims in the same dump you should find an object with the IDs specified in the list. You should match the ID with the object yourself, as you could have multiple instances of the same object around we reference via IDs.

Does that makes sense to you?

Yes, I got the idea now and I found the objects with the same ID somewhere else in the file. Thank you.

Does this also work with assets? I see the ID’s for some of the images but I cannot find the object with the info about this image (heroImage, logo).


Uploads are a different object than items, so you need to fetch the uploads separately and then again match them on your side.