prismicio / prismic-ts-codegen

A Prismic model-to-TypeScript-type generator.
Apache License 2.0
18 stars 6 forks source link

Named export 'createClient' not found. #56

Closed Figumari closed 1 year ago

Figumari commented 1 year ago

Versions

Reproduction

prismicCodegen.config.ts

import type { Config } from "prismic-ts-codegen";
import dotenv from "dotenv";

dotenv.config({ path: ".env.local" });

const config: Config = {
  output: "./types.generated.ts",
  repositoryName: "your-repo-name",
  customTypesAPIToken: process.env.PRISMIC_TS_CODEGEN_API_TOKEN,
  models: {
    fetchFromRepository: true,
  },
};

export default config;

Steps to reproduce

What is expected?

What is actually happening?

Latest version throws error, when loading remote models with the Custom Types API . It works for me with v0.1.11.

Error:

$ npx prismic-ts-codegen
file:///Users/mario/kilokilo-projects/bauen-mit-holz__website/node_modules/prismic-ts-codegen/dist/cli/loadLocaleIDs.js:2
import { createClient } from './../_node_modules/@prismicio/client/dist/createClient.js';
         ^^^^^^^^^^^^
SyntaxError: Named export 'createClient' not found. The requested module './../_node_modules/@prismicio/client/dist/createClient.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from './../_node_modules/@prismicio/client/dist/createClient.js';
const { createClient } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Node.js v18.14.2
error Command failed with exit code 1.
maapteh commented 1 year ago

Same, even when i set not to create a client in my config

LiamJSP commented 1 year ago

This is also happening for me. I can confirm that removing prismic-ts-codegen from the node_modules folder and then running: "npx prismic-ts-codegen@0.1.11 init && npx prismic-ts-codegen@0.1.11" worked for me too for now.

Could this issue be similar to this similar issue with Prisma's client?

timvandenhof commented 1 year ago

Able to reproduce this on: prismic-ts-codegen: v0.1.16 node: v18.17.0

Downgrading to v0.1.11 seeoms to work for me as well

Maxime-Asphalte commented 1 year ago

Same here...

vinnycodes commented 1 year ago

Able to reproduce this on: prismic-ts-codegen: v0.1.16 node: v18.17.0

Downgrading to v0.1.11 seeoms to work for me as well

This worked for me. Will use this for the time being.

lihbr commented 1 year ago

Hey there, sorry for the delay and thanks for contributing!

This should be fixed once #58 lands.

angeloashmore commented 1 year ago

Thanks for everyone's patience (and @lihbr for the fix)!

The issue should be resolved as of v0.1.17. If you still experience the issue, please post here. Thank you!