Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting weird module issue #4

Open
statusunknown418 opened this issue Oct 4, 2023 · 7 comments
Open

getting weird module issue #4

statusunknown418 opened this issue Oct 4, 2023 · 7 comments

Comments

@statusunknown418
Copy link

trying to generate the dbml using default configurations throws this error

SyntaxError: Cannot use import statement outside a module
@L-Mario564
Copy link
Owner

Seems like an ESM/CJS related error. Can you share a snippet of your code?

@statusunknown418
Copy link
Author

I'm using the one from the example:

import { mysqlGenerate } from "drizzle-dbml-generator";
import * as schema from "./src/lib/db/schema";

const out = "./schema.dbml";
const relational = true;

mysqlGenerate({ schema, out, relational });

@L-Mario564
Copy link
Owner

Try setting (or adding) the type property in package.json to module. So:

{
  // ...
  "type": "module"
  // ...
}

You can also try using CJS' require syntax instead. Don't recommend it personally but you could try.
If none of this works, try investigating more about the error elsewhere as well, as the error isn't one that's specific to this package.

@statusunknown418
Copy link
Author

statusunknown418 commented Oct 7, 2023

Problem is that setting module makes nextjs not work at all, actually did that but needed to keep switching the package.json everytime lol

@L-Mario564
Copy link
Owner

You might be forced to use CJS syntax then, which this package should support.

@stromseng
Copy link

Having the same issue, I can't convert my entire project to use require().

@stromseng
Copy link

I fixed this by using tsx instead of ts-node.
so simply "generate-dbml": "tsx dbml.ts",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants