How to use a private Deno module hosted in a private repository?
Hello, I am trying to publish and use a private Deno module from one repository to another. The repositories are hosted on Azure DevOps.
Following the docs and other online resources, there are 2 main ways to do that:
- Publish a npm package with dnt on the Azure DevOps npm private registry,
- Use the raw file directly from the other repo using DENO_AUTH_TOKENS env variable for authentication.
For the first solution, the problem is the module I want to publish uses Deno.Command, and there is currently no support in dnt for converting it (https://github.com/denoland/node_shims/issues/110).
I also tried to create a simpler npm package with only the module's Deno Typescript files. I am able to publish it on the npm private registry, but when I'm using it from another Deno project, there is a runtime issue because Deno doesn't support importing typescript files from npm packages:
For the use of a raw Typescript file imported directly from another Azure DevOps repo, I am not able to have the authentication work properly. I have set DENO_AUTH_TOKENS env variable with a token that works for getting the code, using Basic Auth credentials format from the Deno docs (https://docs.deno.com/runtime/fundamentals/modules/#deno_auth_tokens).
but when I run the script Deno isn't able to reach the file. It is like the token wasn't sent correctly:
What is the proper way to do that? Or is there any other way to consume a Deno module hosted in a private repository without using dnt?
GitHub
Issues · denoland/node_shims
npm packages providing shims for the Deno namespace and other globals. Useful for running Deno-first programs on Node. - Issues · denoland/node_shims
Deno
Modules and dependencies
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno
1 Reply
hey, apologies for posting on an old thread..
did you ever find a better route for publishing deno-specific modules (e.g. uses Deno.Command) to a private NPM to import into other deno programs?
I'm asking because I just had some success DIYing together an NPM build step for a Deno-specific library. To get around your "TypeScript files are not supported in npm packages" error, I'm using
deno bundle to prep each individual file, and then rewriting every import to use .js instead of .ts.
Anyway, I was able to upload my Deno module to a private NPM registry, and then use it in another project with deno add npm:@private/.... And that's pretty cool!
I just have a couple struggles left, like automatic registry authentication, & getting LSP to understand these imports.
Hoping maybe we can share more notes.