drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit@1.0.0-beta.20 missing drizzle-orm peerDependency causes 'Cannot find module' in npm workspaces
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-beta.20
### What version of `drizzle-kit` are you using?
1.0.0-beta.20
### Other packages
npm 11.6.2, Node.js 24.13.0
### Describe the Bug
`drizzle-kit@1.0.0-beta.20`'s `bin.cjs` does external `require('drizzle-orm/...')` calls (line 59-67), but `drizzle-orm` is not declared as a `peerDependency` or `dependency` in the published package.
In the source repo, `drizzle-orm` is listed as a `devDependency` with `workspace:./drizzle-orm/dist`. This `workspace:` path reference is published as-is to npm (pnpm does not transform `workspace:./path` syntax during publish, only `workspace:*` / `workspace:^`).
**Published `drizzle-kit@1.0.0-beta.20` on npm:**
```json
{
"dependencies": {
"@drizzle-team/brocli": "^0.11.0",
"@js-temporal/polyfill": "^0.5.1",
"esbuild": "^0.25.10",
"get-tsconfig": "^4.13.6",
"jiti": "^2.6.1"
},
"devDependencies": {
"drizzle-kit": "^0.31.6",
"drizzle-orm": "workspace:./drizzle-orm/dist"
}
}
```
Note: `drizzle-orm` is completely absent from `dependencies` and `peerDependencies`.
**bin.cjs requires drizzle-orm externally:**
```js
// bin.cjs lines 59-67
let drizzle_orm__relations = require("drizzle-orm/_relations");
let drizzle_orm = require("drizzle-orm");
let drizzle_orm_pg_core = require("drizzle-orm/pg-core");
let drizzle_orm_casing = require("drizzle-orm/casing");
// ... etc
```
This works by accident in flat `node_modules` layouts where `drizzle-orm` happens to be hoisted to the root. But it breaks in npm workspaces when another package has a conflicting peer dependency on `drizzle-orm` (e.g., `fraci@0.18.0` requires `drizzle-orm >= 0.30.0 < 0.45.0`), preventing npm from hoisting `drizzle-orm@1.0.0-beta.20` to the root `node_modules/`.
In this case `drizzle-kit` is hoisted to root `node_modules/drizzle-kit/`, but `drizzle-orm` only exists in each workspace's `node_modules/`, so `require('drizzle-orm/_relations')` fails.
### Expected behavior
`drizzle-kit` should declare `drizzle-orm` as a `peerDependency` in `package.json`:
```json
{
"peerDependencies": {
"drizzle-orm": ">=1.0.0-beta.1"
}
}
```
This would tell npm that `drizzle-kit` needs `drizzle-orm` available at runtime and ensure proper resolution in monorepo/workspace setups.
### Environment & setup
- OS: macOS (Darwin 25.4.0)
- Package manager: npm 11.6.2
- Monorepo: npm workspaces
- Node.js: 24.13.0
### Reproduction
1. Create an npm workspace monorepo
2. Add `drizzle-orm@1.0.0-beta.20` and `drizzle-kit@1.0.0-beta.20` to a workspace package
3. Add another dependency that has a conflicting peer dep on `drizzle-orm` (e.g., `fraci@0.18.0` which requires `drizzle-orm < 0.45.0`)
4. Run `npm install`
5. Run `drizzle-kit generate`
```
Error: Cannot find module 'drizzle-orm/_relations'
Require stack:
- /path/to/node_modules/drizzle-kit/bin.cjs
```
### Workaround
Add `drizzle-orm` to the root `package.json` dependencies and use `--legacy-peer-deps` to force hoisting despite the peer dep conflict.
Contributor guide
Research direction
Start by checking the drizzle-kit package manifest and the generated bin.cjs entry point, especially the external drizzle-orm requires on lines 59-67. Reproduce the install in an npm workspace with the conflicting peer dependency, then verify that the published package declares the runtime requirement and that drizzle-kit generate no longer reports the missing module.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100