DEV Community

Cover image for How Deno differs from Node.js
Dawit
Dawit

Posted on • Originally published at oneminch.dev on

How Deno differs from Node.js

Deno improves upon Node.js in some significant ways.

Modules

Modules are loaded directly from URLs and cached locally.

import confetti from "https://esm.sh/canvas-confetti@1.6.0";
Enter fullscreen mode Exit fullscreen mode

This allows the decentralization of packages by removing reliance on npm and enabling developers to self-host their packages.

Consequently, this removes the need for package.json and node_modules, and allows programs to run in the browser since there is no reliance on build tools like Webpack.

Security

Because code is executed in a sandbox, the Deno runtime has no access to the file system and the network. Flags like --allow-write and --allow-net can be used to explicitly enable access.

Other Features

In addition to the above features, Deno supports TypeScript out of the box and has a built-in formatter for code similar to ESLint for Node.js.

Top comments (0)

typescript

11 Tips That Make You a Better Typescript Programmer

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!