Fjeldstad
Fjeldstad
DTDrizzle Team
Created by Fjeldstad on 2/13/2024 in #help
Missing dependency on drizzle-orm in drizzle-kit?
I'm using NPM workspaces, and for some reason when I installed drizzle-orm it was placed in the node-modules of that specific workspace, rather than the root. I think it was due to a conflict of the react peer dependency (why is an ORM even depending on React?) - I have an older verison of React already installed and located in the root node_modules. Anyway, when I installed drizzle-kit as a dev dependency, it installed it in the root node_modules. Then when I run drizzle-kit generate:pg , it fails to resolve drizzle-orm/pg-core - probably related to the fact that that module is located in a workspace-local node_modules, but not sure. This is the rough structure that I ended up with after running npm install drizzle-orm --workspace my-workspace and npm install --save-dev drizzle-kit --workspace my-workspace:
/node_modules
/drizzle-kit
/workspaces
/my-workspace
/node_modules
/drizzle-orm
/node_modules
/drizzle-kit
/workspaces
/my-workspace
/node_modules
/drizzle-orm
And again, running npm exec --workspace my-workspace -- drizzle-kit generate:pg (or through an NPM script in /workspaces/my-workspace/package.json) results in a module resolution error:
npm run drizzle:generate -w my-workspace

> drizzle:generate
> drizzle-kit generate:pg

node:internal/modules/cjs/loader:1080
throw err;
^

Error: Cannot find module 'drizzle-orm/pg-core'
Require stack:
- /.../my-app/node_modules/drizzle-kit/bin.cjs
[...]
code: 'MODULE_NOT_FOUND',
requireStack: [ '/.../my-app/node_modules/drizzle-kit/bin.cjs' ]
}

Node.js v18.17.1
npm ERR! Lifecycle script `drizzle:generate` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: my-workspace
npm ERR! at location: /.../my-app/workspaces/my-workspace
npm run drizzle:generate -w my-workspace

> drizzle:generate
> drizzle-kit generate:pg

node:internal/modules/cjs/loader:1080
throw err;
^

Error: Cannot find module 'drizzle-orm/pg-core'
Require stack:
- /.../my-app/node_modules/drizzle-kit/bin.cjs
[...]
code: 'MODULE_NOT_FOUND',
requireStack: [ '/.../my-app/node_modules/drizzle-kit/bin.cjs' ]
}

Node.js v18.17.1
npm ERR! Lifecycle script `drizzle:generate` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: my-workspace
npm ERR! at location: /.../my-app/workspaces/my-workspace
Has anyone stumbled into this? Any suggestions on
2 replies