Home > database >  What is the standard way to publish a Deno application for other people to use?
What is the standard way to publish a Deno application for other people to use?

Time:11-21

When I create an application on Node.js, I perform the following steps to publish it for other people:

  1. Add a main.js file, which calls node:
#!/usr/bin/env -S node --stack-size=10000

console.log("Hello world!")
  1. Include it on package.json:
  ...
  "name": "my_app",
  ...
  "bin": {
    "my_app": "src/main.js"
  },
  ...
  1. Type npm publish.

And done: anyone can then now install it by typing npm i -g my_app, and it will be made available to use on the terminal by typing my_app. What are the equivalent steps to publish an application built using Deno instead?

CodePudding user response:

Since deno uses urls for dependencies you do not need to publish anything from your cli. You can simply host it as a public repo on github. Then you can add it to their third-party library here by clicking on the 'publish a module' button

CodePudding user response:

How to publish a Deno command-line application

  1. Create an entry file (ex: main.ts).

  2. Host your project somewhere.

  3. Install it anywhere using the URL to main.ts:

deno install -n your_app https://your_url/your_app/main.ts

Passing options

You can pass Deno options in the same way you would for deno run:

deno --unstable install -n your_app --allow-all URL_HERE

Using Github

If you have a Github repository, you can get a URL to your file by browsing to it, and clicking on "Raw". It will be something like:

https://raw.githubusercontent.com/your_org/your_app/tree/master/main.ts

This URL can be used to install your app.

Using deno.land/x

You can also register a Github repository on https://deno.land/x. This will give you a shorter url:

https://deno.land/x/your_app/main.ts

As well as a way to keep track of immutable versions:

https://deno.land/x/your_app@version/main.ts

Thanks for the devs on Deno's Discord for the help.

  • Related