Prints "Hello world!".
From terminal:
console.log('Hello world!')
From URL:
deno run https://raw.githubusercontent.com/bolzon/deno-handson/main/samples/hello.ts
Demo:
Module cache: modules imported in deno are cached such as
<script>
tag in browser.
Fetch remote content in different ways.
Access to network needs explicit permission (--allow-net
).
deno run --allow-net <script>
Demos:
How to start a simple HTTP server.
No external modules needed; uses the Deno Standard Library.
Demo:
Read a text file.
Access to read files needs explicit permission (--allow-read
).
deno run --allow-read <script>
Demo:
Write a text file.
Access to write files needs explicit permission (--allow-write
).
deno run --allow-write <script>
Demo:
Scripts can be compiled into a single executable file.
deno compile --unstable <OUT>
Deno has a built-in file watcher (like nodemon
) to restart a script that was changed on disk.
deno run --watch --unstable --allow-net http-server.ts
Deno has a built-in code formatter that auto formats TypeScript and JavaScript code.
deno fmt # all files
deno fmt file.ts # only file.ts
It's also possible just to check the file (diff) format instead of applying it by adding --check
flag.
deno fmt --check # checks format only
Deno has a built-in code linter for TypeScript and JavaScript.
deno lint --unstable # all files
deno lint --unstable file.ts # only file.ts