These are useful commands for working with different runtimes (Node.js, and Deno) and managing Deno's caching, modules, and directories.
-
Benchmark runtimes:
hyperfine "node bench.js" "deno run bench.js" --warmup=100 -i
This command benchmarks the performance of running the
index.js
file using Node.js, and Deno. The--warmup=100
flag ensures that each command is warmed up 100 times before measurement, and-i
runs the benchmarking interactively. -
Deno info command:
deno info "https://docs.deno.com/examples/hello-world.ts"
This fetches and provides information about the
hello-world.ts
file from the given URL, including its dependencies and module tree. -
Deno run with cache reload:
deno run --reload main.ts
This runs the
main.ts
file while forcing a cache reload of the modules to ensure the latest versions are used. -
Open Deno's cache:
open ~/Library/Caches/deno/
Opens the default cache directory on macOS where Deno stores its downloaded modules and files.
-
Create a new Deno directory:
mkdir deno_dir
Creates a new directory named
deno_dir
where you can specify a custom cache location for Deno. -
Set a custom Deno directory:
export DENO_DIR=./deno_dir/
This exports the
DENO_DIR
environment variable, directing Deno to use the newly createddeno_dir
as its cache. -
Cache specific files:
deno cache main.ts
Caches the dependencies of the
main.ts
file for future use, allowing faster execution as it doesn’t have to be downloaded each time. -
Add a module with Deno:
deno add jsr/......
Adds a specific JavaScript or TypeScript module, using Deno's built-in package management capabilities (the full path should replace the
jsr/......
part). -
Use custom Deno cache directory in commands:
$DENO_DIR DENO_DIR=./deno_dir/ deno main.ts
The first command shows the current value of
DENO_DIR
, and the second command runs themain.ts
file using thedeno_dir
as the custom cache directory. -
To install Deno Jupyter, run the following command:
deno jupyter --unstable --install
- Upgrade to Deno 2.0 Release Candidate:
deno upgrade
deno upgrade rc
- JSR Standard Library: An evolving JavaScript/TypeScript standard library repository.
- Deno Third-Party Modules: Official repository for third-party Deno modules.
- Deno Documentation: Deno documentation on TypeScript support and runtime fundamentals.