- Secure defaults: Explicit permission must be granted for your Deno applications in order to access disk, network, and runtime environments.
- Native TypeScript support: No tsconfig needed—Deno acts like a native TypeScript runtime. Under the hood Deno still transpiles and bundles TypeScript files.
- Ability to import ES Modules directly from URLs: No more NPM—dependencies can be imported directly via URL or file path:
Deno’s approach to ES Modules is generating a lot of debate around package management, especially concerning security. For example, will this prevent another left-pad incident? Regardless of your gut reaction, I highly recommend reading the docs.
I think the explicitness of import-from-URL will make developers think carefully about dependency management; however, I suspect many teams will handle this problem similarly to how they handle npm: with lock files, proxies, and white-listed internal registries.
Deno also includes less-cited features that I’m excited about:
- Bundler: Deno can bundle your application and its dependencies into a single file.
- Script Installer: Deno can install a script from any URL, add its command-line alias to PATH, and requires explicit permissions during installation. Wow!
- Async Standard Library: Deno standard APIs use async/await and async iterators.
- Built-in test framework: Deno includes a built-in test framework with top-level async support.
Enough talk, let’s take Deno for a spin by building a simple web app:
# run locally deno run demo.ts # run from remote URL deno run https://gist.githubusercontent.com/robzhu/ef4e76d27ca50a920a9e5b4aebb40ab9/raw/6bef3fa5eb6bca5f439c3fde75ce2e39cf4cd451/demo.ts
Either way, you should see an error:
error: Uncaught PermissionDenied: network access to "0.0.0.0:8000", run again with the --allow-net flag at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11) at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10) at Object.listen ($deno$/ops/net.ts:51:10) at listen ($deno$/net.ts:152:22) at serve (https://email@example.com/http/server.ts:261:20) at https://gist.githubusercontent.com/robzhu/ef4e76d27ca50a920a9e5b4aebb40ab9/raw/6bef3fa5eb6bca5f439c3fde75ce2e39cf4cd451/demo.ts:3:11
Since this is an HTTP server, we need to grant explicit permissions for network access:
# run locally deno run --allow-net demo.ts # run from remote URL deno run --allow-net https://gist.githubusercontent.com/robzhu/ef4e76d27ca50a920a9e5b4aebb40ab9/raw/6bef3fa5eb6bca5f439c3fde75ce2e39cf4cd451/demo.ts
Now you should be able to test your server by navigating to http://localhost:8000/hi. So far so good, but that URL is quite long: Is there an easy way to install it as a script?
deno install --allow-net -n denohttp https://gist.githubusercontent.com/robzhu/ef4e76d27ca50a920a9e5b4aebb40ab9/raw/6bef3fa5eb6bca5f439c3fde75ce2e39cf4cd451/demo.ts # run the script: denohttp
I hope this post has given you an overview of Deno.