Deno: Ability to create global modules

Created on 5 Feb 2019  路  5Comments  路  Source: denoland/deno

I would like to suggest a deno builtin module that would abstract out the development of global modules with deno.

executing deno -g url should make that module available globally by

  • Creating a script for it
  • Add permissions for it
  • Export the path

All 5 comments

Globals are bad. What is the use case?

@kitsonk something like ng and nodemon in node...

You can install them via npm or yarn, though, same for windows-build-tools and pm2 (which I use, and require global installation)

@kyranet I agree but i'm referring to deno specific library, let us say something similar to ng is built for deno how can we make it available as a global command...

Part of the beauty of Deno is that it's based on more generic standards. In this case, a "global command" could just be a plain old shell alias or executable in your PATH.

Let's pretend denomon is a thing and its source code is:

#!/usr/bin/env deno

console.log('I am denomon');

Now when we want to make it a global command...

Solution 1: Use a shell alias

# In your bash profile
alias denomon='deno https://deno.land/x/denomon'

Solution 2: Put the executable in PATH

$ curl https://deno.land/x/denomon -s -o /usr/local/bin/denomon
$ chmod +x /usr/local/bin/denomon

And that's it. Using those techniques, you can then run denomon from anywhere as a global command.

Solution 2 is actually what npm install -g does, basically. Except npm uses a lot of Node-specific shenanigans in the processes of doing it, whereas Deno doesn't need to. That said, you could totally npm install -g denomon and use it with Deno! You'd just have to include a superfluous package.json to make npm happy.

I agree it would be nice if Deno had a built-in command for convenience and to make Deno more familiar for folks who are used to Node. My point is just that, even without a built-in command, this is still very easy thanks to Deno's design.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CruxCv picture CruxCv  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments

ry picture ry  路  3Comments

davidbarratt picture davidbarratt  路  3Comments

sh7dm picture sh7dm  路  3Comments