Slice Manager import issue

Hi Prismic team,

I’m trying to run the fetch-models.ts script described in the slice machine migration doc, but I receive this error

Would you be able to help?

Impacted feature

Slice Machine Manager

What steps have you taken to resolve this issue already?

  • The error is coming from “node_modules/@slicemachine/manager/dist/managers/customTypes/CustomTypesManager.js:6”
  • Looking at “node_modules/@prismicio/types-internal/lib/customtypes/CustomType.js:54”, I see the export defined: exports.CustomType = customTypeReader(Section_1.DynamicSection);

Errors

SyntaxError: The requested module '@prismicio/types-internal/lib/customtypes' does not provide an export named 'CustomType'

Your Role

Developer

Hosting provider

Not relevant

Package.json file

Using Node v22.18.0

    "dependencies": {
        "@nuxt/eslint": "^1.13.0",
        "@nuxt/fonts": "^0.13.0",
        "@nuxt/image": "^2.0.0",
        "@nuxt/scripts": "^0.13.2",
        "@prismicio/client": "^7.21.4",
        "@slicemachine/manager": "^0.27.1",
        "@unhead/vue": "^2.1.2",
        "eslint": "^9.39.2",
        "nuxt": "^3.21.0",
        "p-limit": "^7.2.0",
        "vue": "^3.5.27",
        "vue-router": "^4.6.4"
    },
    "devDependencies": {
        "@nuxtjs/prismic": "^5.2.0",
        "@slicemachine/adapter-nuxt": "^0.3.95",
        "netlify-cli": "^23.14.0",
        "sass-embedded": "^1.97.3",
        "slice-machine-ui": "^2.21.1"
    }

Steps to reproduce

  • Run npx tsx fetch-models.ts in the repository
  • The error appears on the first line: import { createSliceMachineManager } from "@slicemachine/manager"

Hi Thomas,

This looks like an ESM/CJS interoperability issue on our side, but it can also depend on how your project is configured.

Since I don’t have your exact setup, here are a few things worth checking on your end:

  • package.jsontype field
    If you have "type": "module", try temporarily removing it and run the script again. That can change how Node resolves exports.

  • tsconfig.jsonmodule and moduleResolution
    Check what you’re using there (NodeNext, Node16, CommonJS, etc.). A mismatch between your TS config and how Node executes the file (especially with tsx) can cause this kind of export error.

If none of that helps, could you share:

  • your tsconfig.json

  • your package.json

That will help narrow it down properly.

Xavier

Hi @xavier.rutayisire,

  • Removing “type”: “module” is far from ideal, but does the trick :+1:
  • I had found a workaround using Jiti to run the script

Thanks!

1 Like