Can Deno automatically install peerdeps like NPM does?
I have a framework that bundles Svelte, and Svelte is marked as peer dependency.
This works flawlessly when I use npm/pnpm/bun, but with
deno run
, it's missing all the peer dependencies, and would force the user to install them manually.
Is there a recommended solution to this?1 Reply
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, it's important to note that Deno does not have a package.json file like npm, and it does not handle dependencies in the same way as npm does. Deno imports modules directly from URLs, and it caches them upon the first import. There is no direct equivalent to npm's automatic handling of peer dependencies in Deno.
Since Deno does not have a built-in mechanism for automatically managing peer dependencies like npm, you would typically need to ensure that all required dependencies are explicitly imported in your code. If your framework relies on peer dependencies, you may need to document the required imports so that users of your framework can include them in their projects.
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. For a recommended solution, you might want to explore community practices or reach out to the Deno community for patterns that others have adopted when dealing with similar situations.