How do I run an npm script with multiple dependencies, e.g. `drizzle-kit generate:pg`?
I thought about wrapping it into a task
"generate": "deno run -A npm:drizzle-kit generate:pg"
in the deno.json
file, but I'm getting in that case3 Replies
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the message you provided, it seems like there might be an issue with how you're trying to run the npm script within Deno.
In Deno, there isn't a direct equivalent to npm scripts as you would have in a Node.js environment. Deno tasks in the
deno.json
file are used to run Deno-specific commands. If drizzle-kit
is an npm package and you're trying to use it within Deno, you would typically need to use a compatibility layer or a tool that allows you to import npm packages in Deno.
However, the error message you're seeing suggests that the module 'drizzle-orm/pg-core'
cannot be found. This could be due to a variety of reasons, such as the module not being installed correctly, or the module not being compatible with Deno.
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If you continue to experience issues, you may want to consider reaching out to the maintainers of drizzle-kit
or looking for community support in forums or chat groups that focus on Deno and the specific packages you are using.It looks like we have a few issues at play here.
The first is that
drizzle-kit
expects that drizzle-orm
has already been installed to node_modules
in the current folder (it doesn't work if you run npx drizzle-kit generate:pg
without doing this either). My recommendation here is that (for now) you manage these dependencies with an npm client.
Once you do this, however, running
Still produces an error. This is an npm compatibility error that has been reported here: https://github.com/denoland/deno/issues/19826 - it would appear that we don't have the right shims in place for the worker thread API for core Node.
To run the migration generation, you'd need to run this through Node today as well 😦
However, the actual client code works just fine in Deno:
Gist
Drizzle on Deno Workaround
Drizzle on Deno Workaround. GitHub Gist: instantly share code, notes, and snippets.