drizzle-team / drizzle-team/drizzle-orm

drizzle-kit: ""import.meta" is not available" error

Open
#3,304 9 comments 8 reactions 0 assignees View on GitHub
docs docs/undocumented drizzle/kit
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

I am using drizzle-kit in my project with the Vite development server. At the same time, the schema files are located in different directories of my project, inside the src folder.

When I try to execute the drizzle-kit pull or drizzle-kit generate command, an error occurs:

```
> drizzle-kit push

drizzle-kit: v0.21.2
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file '/my-app-path/drizzle.config.ts'
Using 'pg' driver for database querying
{
column: 54,
file: '/my-app-path/src/utils/libs/i18n/i18n.ts',
length: 11,
line: 22,
lineText: "const modules: Record = import.meta.glob('/translations/*.json', {",
namespace: '',
suggestion: ''
}
"import.meta" is not available with the "cjs" output format and will be empty
TypeError: import_meta.glob is not a function
at Object. (/my-app-path/src/utils/libs/i18n/i18n.ts:22:67)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._compile (/my-app-path/node_modules/drizzle-kit/bin.cjs:11751:31)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Object.newLoader [as .ts] (/my-app-path/node_modules/drizzle-kit/bin.cjs:11755:13)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at Object. (/my-app-path/src/utils/libs/i18n/index.ts:2:15)
```

This is most likely due to the fact that when it try to run schema files, files containing Vite-specific code are run too.

Please specify is there a way to fix this?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.