Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


Deno CLI sample commands

Shahpar Khan
svg viewer

What is Deno?

Deno is a JavaScript/TypeScript runtime with secure defaults and great developer experience. It’s built on V8, Rust, and Tokio.

Deno aims to be a productive and secure scripting environment for the modern programmer. Deno will always be distributed as a single executable. Given a URL to a Deno program, it is runnable with nothing more than the ~15 megabytes zipped executable.

Deno has its dedicated Command Line Interface (CLI) for basic shell usage.

Deno CLI

Deno CLI lets you interact with the Deno environment using shell commands. To see all the shell commands, you can invoke help in the following three ways:

# Using the subcommand.
deno help

# Using the short flag -- outputs the same as above.
deno -h

# Using the long flag -- outputs more detailed help text where available.
deno --help

You can also see details about a specific built-in tool. For example, there is a documentation generator tool with the command doc. To get the details about the doc command, you can run either of the following three commands:

### 1.
deno help doc
### 2.
deno doc -h
### 3.
deno doc --help

Deno provides built-in tooling that is useful when working with JavaScript and TypeScript:

Running Scripts

You can run scripts in the Deno shell via multiple sources: a filename, a url, or ‘-’ to read the file from stdin.

### running script using a filename
deno run main.ts

### running script using a url
deno run

### Running script using stdin
cat main.ts | deno run -

Adhere to the following format while adding flags and script arguments: deno run {flags} {source} {script arguments}

Other flags

There are a few more flags that you can use in the Deno CLI:

  • Watch flag --watch: Deno starts up with this flag that watches the entrypoint and all local files the entrypoint statically imports. Whenever one of these files is changed on disk, the program will automatically restart.

  • Integrity flag --lock: Affects commands that can download resources to the cache, i.e., deno cache, deno run, and deno test.

  • Cache and configuration flags: Affects commands that can populate the cache, i.e., deno cache, deno run, and deno test.

  • Permission flags: Deno is secure by default. Therefore, unless you specifically enable it, a deno module has no file, network, or environment access.

  • Runtime flags: Affects commands that execute user code, deno run and deno test. These include everything above.




Shahpar Khan
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring