You are viewing documentation generated from a user contribution or an upcoming release. The contents of this document may not have been reviewed by the Deno team. Click here to view the documentation for the latest release.

Making Scripts Executable With a Hashbang (Shebang)


  • Deno.env provides the environment variables.
  • env runs a program in a modified environment.


Making Deno scripts executable can be useful if you want to make, for example, small tools.

Note: Hashbangs do not work on Windows.


In this program we give the context permission to access the environment variables and print the Deno installation path.

#!/usr/bin/env -S deno run --allow-env

 *  hashbang.ts

const path = Deno.env.get("DENO_INSTALL");

console.log("Deno Install Path:", path);


You may require to give the script execution permissions.


sudo chmod +x hashbang.ts


Start the script by calling it like any other command:



  • A hashbang has to be placed in the first line.

  • -S splits the command into arguments.

  • End the file name in .ts for the script to be interpreted as TypeScript.

  • Future plans include supporting the command-line option --ext <type>, relieving this naming restriction. See denoland/deno#5088.