About
Deno can run JavaScript and TypeScript with no additional tools or configuration required, unlike Node which will require some additional libraries and configurations to work with it.
Additionally Deno by default can work as HTTP Server, Routes, Database access, and more.
Installing Deno
Installing on Linux is simple:
Check verion with:
Deno Project
Deno configuration file is deno.json which is similar to the package.json from Node.
It will automatically recognize this file in project root folder, but an arbitrary path to the configuration file can be passed through the --config flag when executing Deno.
If both deno.json and package.json are present Deno will understand dependencies specified in both.
Use deno.json for Deno-specific configurations.
Also check more info in About.
deno.json
Check a full example of the configuration file here.
The "imports" field in your deno.json allows you to specify dependencies used in your project.
You can use it to map bare specifiers to URLs or file paths making it easier to manage dependencies and module resolution in your applications.
The "tasks" field in your deno.json file is used to define custom commands that can be executed with the deno task command and allows you to tailor commands and permissions to the specific needs of your project. (Just like "scripts" from Node)
The "lint" field in the deno.json file is used to configure the behavior of Deno’s built-in linter.
This allows you to specify which files to include or exclude from linting, as well as customize the linting rules to suit your project’s needs.
The "fmt" field in the deno.json file is used to configure the behavior of Deno’s built-in code formatter.
This allows you to customize how your code is formatted, ensuring consistency across your project, making it easier to read and collaborate on.
The "lock" field in the deno.json file is used to specify configuration of the lock file that Deno uses to ensure the integrity of your dependencies.
You can disable Deno from creating the deno.lock file with:
Since Deno by default always add new added dependencies to the lockfile, it is also possible to freeze this lockfile (ex. CI pipelines or production environments) so that Deno will error when it encounter dependencies it's never seen before.
To do this you can pass the --frozen flag or add the configuration to deno.json.
The "compilerOptions" field in the deno.json file is used to configure TypeScript compiler settings for your Deno project.
Many of the configurations in deno.json can accept include and exclude properties.
Check more detailed info on the docs.
Node and Npm Support
Node.js
Deno provides a compatibility layer that allows the use of Node.js built-in APIs within Deno programs.
However, in order to use them, you will need to add the node: specifier to any import statements that use them.
And run it with deno run main.mjs.
Npm
Deno has native support for importing npm packages by using npm: specifiers. For example:
No npm install is necessary before the deno run command and no node_modules folder is created.
Importing types
Many npm packages ship with types, you can import these and use them with types directly:
node file.js
deno file.js
ts-node file.ts
deno file.ts
nodemon
deno run --watch
node -e
deno eval
npm i / npm install
deno install
npm install -g
deno install -g
npm run
deno task
eslint
deno lint
prettier
deno fmt
package.json
deno.json or package.json
tsc
deno check
typedoc
deno doc
jest / ava / mocha / tap / etc
deno test
nexe / pkg
deno compile
npm explain
deno info
nvm / n / fnm
deno upgrade
tsserver
deno lsp
nyc / c8 / istanbul
deno coverage
benchmarks
deno bench
Examples
Bellow some examples on doing things with Deno.
Files
Network
Subprocess
Error Handling
Permissions
Storage
NodeJs Modules
Continuos Integration (CI)
Last updated