On this page
deno run
, run a file
deno run [OPTIONS] [SCRIPT_ARG]
run a JavaScript or TypeScript file.
Usage Jump to heading
To run the file at https://examples.deno.land/hello-world.ts use:
deno run https://examples.deno.land/hello-world.ts
You can also run files locally. Ensure that you are in the correct directory and use:
deno run hello-world.ts
By default, Deno runs programs in a sandbox without access to disk, network or
ability to spawn subprocesses. This is because the Deno runtime is
secure by default. You can grant or
deny required permissions using the
--allow-*
and --deny-*
flags.
Permissions examples Jump to heading
Grant permission to read from disk and listen to network:
deno run --allow-read --allow-net server.ts
Grant permission to read allow-listed files from disk:
deno run --allow-read=/etc server.ts
Grant all permissions this is not recommended and should only be used for testing:
deno run -A server.ts
If your project requires multiple security flags you should consider using a
deno task
to execute them.
Watch Jump to heading
To watch for file changes and restart process automatically use the --watch
flag. Deno's built in application watcher will restart your application as soon
as files are changed.
Be sure to put the flag before the file name eg:
deno run --allow-net --watch server.ts
Deno's watcher will notify you of changes in the console, and will warn in the console if there are errors while you work.
Running a package.json script Jump to heading
package.json
scripts can be executed with the deno task
command.
Running code from stdin Jump to heading
You can pipe code from stdin and run it immediately with:
curl https://examples.deno.land/hello-world.ts | deno run -
Terminate run Jump to heading
To stop the run command use ctrl + c
.