Resolving Dependencies for Local ESM NPM Packages in Deno
Hi Deno Community,
I'm seeking guidance on the best approach for a setup involving a Deno application and a local, unpublished npm package using ESM. I'm having trouble with Deno automatically resolving the npm package's dependencies without explicit declarations in Deno's config file.
Here's the project structure:
package2 Structure:
* package2/src/index.ts:
* package2/package.json:
* deno-app/main.ts:
* deno-app/deno.json:
5 Replies
The Problem:
With the above configuration, how can I configure the Deno app so that it does not need any imports for
uuid, marked, or lodash? All I want to do is for it to import package2 but have all of its dependencies pulled and loaded as well. How can I make Deno automatically detect and resolve the dependencies of my local NPM package without me having to manually specify them in the deno.json?
Steps Taken:
1. Ensured "type": "module" is set in package2/package.json.
2. Built package2 using tsc (npm run build).
3. Attempted to import package2 into Deno without listing package2 dependencies in deno.json.
Thank you.@bartlomieju Please help here
You need to use workspace to tell Deno that
package1 and package2Deno
Workspaces and monorepos
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno
it will work by that way with esm manner?
thanks a lot @bartlomieju! it worked in deno workspace manner.