See Deno Introduction.
$ deno --version
deno 1.35.0 (release, aarch64-apple-darwin)
v8 11.6.189.7
typescript 5.1.6
- 1. Introduction
- 2. Getting started
- 3. Basics
- 4. Node and npm modules
- 5. The Runtime
- 6. Examples
- 7. Tools
- 8. Advanced
- 9. References
- 10. Help
Run the following command and see http://localhost:8080/?pokemonNumber=151 on your browser.
deno task pokemon
Build and run:
deno task compile:pokemon
./pokemon
deno init
creates 4 files below:
main.ts
main_test.ts
main_bench.ts
deno.jsonc
deno init
deno run main.ts
See docs about watch mode for more details.
deno run --watch main.ts
Deno provides secure defaults. Unless specifically allowed, scripts can’t access files (read / write files), the environment, or the network.
- Allow "read"
deno run --allow-read main.ts
- Allow "write"
deno run --allow-write main.ts
- Allow "network access"
deno run --allow-net main.ts
Warning 引数の渡し方に注意。渡し方によって Deno ランタイムのフラグとして consume されない場合がある。詳しくは 2.4 Command Line Interface - Script arguments を参照。
deno run [URL]
Some examples of running remote files:
deno run https://deno.land/std@0.193.0/examples/welcome.ts
# Welcome to Deno!
deno run --allow-read https://deno.land/std@0.193.0/examples/cat.ts main.ts
# export function add(a: number, b: number): number {
# return a + b;
# }
#
# // Learn more at https://deno.land/manual/examples/module_metadata#concepts
# if (import.meta.main) {
# console.log("Add 2 + 3 =", add(2, 3));
# }
See Deno std/examples for more examples.
Tasks are defined in deno.jsonc
. See 7.10 deno task
deno task dev
- Example of
deno.jsonc
{
"tasks": {
"dev": "deno run --watch main.ts"
}
}
See Deno official Manual 3.8 Testing.
deno test
deno bench
See Deno official Manual 3.9 Debugging.