fcrozatier
fcrozatier7d ago

Installing packages locally with Deno

I want a local copy of a foo js (node) module in my project that I'll be able to serve to the browser directly (no bundling). If I add it with deno add npm:foo then I can reference the module in my code but the browser won't be able to resolve foo. So I would like to know how I can make a local install with Deno (that's not in the global cache but in my local project), so that I just need to serve this folder and add an importmap script to tell the browser how to resolve foo. I could just npm install foo to have it in a local node_modules folder, but there must be a way to do this in Deno? https://docs.deno.com/runtime/reference/cli/add/#options
Deno
deno add
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno
1 Reply
fcrozatier
fcrozatierOP7d ago
Figured it out. To enable local installs you need to set the nodeModulesDir: "auto" in your config https://docs.deno.com/runtime/fundamentals/node/#node_modules
Deno
Node and npm support
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno

Did you find this page helpful?