new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Deno · Reference · all subjects

runtime/env-variables

33 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

DENO_V8_FLAGS special environment variable

DENO_V8_FLAGS sets V8 command line options.

DENO_NO_UPDATE_CHECK special environment variable

DENO_NO_UPDATE_CHECK disables checking if a newer Deno version is available.

Deno.env API for environment variables

The Deno runtime offers built-in support for environment variables through Deno.env. It has getter and setter methods: Deno.env.set(key, value) to set a variable, Deno.env.get(key) to retrieve a variable, and Deno.env.has(key) to check if a variable exists.

Using --env-file flag to load environment variables

Use the --env-file flag with deno run to read environment variables from a .env file. The flag automatically reads from the .env file in the current working directory or the first parent directory that contains one. You can specify a different file as a parameter to the flag, and you can pass multiple --env-file flags to load variables from multiple files.

.env file variable precedence with multiple files

When multiple declarations for the same environment variable exist within a single .env file, the first occurrence is applied. When the same variable is defined across multiple .env files (using multiple --env-file arguments), the value from the last file specified takes precedence.

@std/dotenv load function for environment variables

The @std/dotenv package provides a load function to load environment variables from .env files. The load function accepts options: envPath (defaults to ".env") to specify the path to the .env file, and export (boolean) to optionally export variables to the process environment so they can be read via Deno.env.

Setting environment variables in deno task commands

You can set environment variables when running deno task commands by using the format VARIABLE_NAME=value before the command in deno.json task definitions. For example, a task can use "command": "BUILD_TYPE=FULL deno run main.ts" to set an environment variable for that specific task execution.

DENO_AUTH_TOKENS special environment variable

DENO_AUTH_TOKENS is a semi-colon separated list of bearer tokens and hostnames used when fetching remote modules from private repositories. Format: token1@hostname1;token2@hostname2 (e.g., abcde12345@deno.land;54321edcba@github.com).

DENO_TLS_CA_STORE special environment variable

DENO_TLS_CA_STORE is a comma-separated list of order-dependent certificate stores. Possible values are: system, mozilla. Defaults to mozilla.

DENO_CERT special environment variable

DENO_CERT loads certificate authorities from a PEM encoded file. The file can contain more than one certificate, each in its own PEM block. This is the environment variable form of the --cert flag.

NODE_EXTRA_CA_CERTS special environment variable

NODE_EXTRA_CA_CERTS specifies a path to a PEM file with extra certificate authorities. These are loaded at the root certificate store level and are honored by fetch(), Deno.connectTls(), and Node compat APIs (node:https, node:tls). Available in Deno 2.8+. Missing or invalid files emit a warning rather than failing, matching Node.js behavior.

DENO_COVERAGE_DIR special environment variable

DENO_COVERAGE_DIR sets the directory for collecting coverage profile data. This option only works for the deno test subcommand.

DENO_DIR special environment variable

DENO_DIR sets the cache directory for Deno.

DENO_INSTALL special environment variable

DENO_INSTALL is used by the shell install script to choose where the deno executable is installed. The binary is placed at $DENO_INSTALL/bin/deno.

DENO_INSTALL_ROOT special environment variable

DENO_INSTALL_ROOT sets the installation root for deno install. Executables are placed in its bin subdirectory, unless the path already ends with bin. Defaults to $HOME/.deno (executables go to $HOME/.deno/bin).

DENO_REPL_HISTORY special environment variable

DENO_REPL_HISTORY sets the REPL history file path. History file is disabled when the value is empty. Defaults to $DENO_DIR/deno_history.txt.

DENO_NO_PACKAGE_JSON special environment variable

DENO_NO_PACKAGE_JSON disables auto-resolution of package.json.

DENO_CONDITIONS special environment variable

DENO_CONDITIONS is a comma-separated list of custom conditions to use when resolving npm package exports. This is equivalent to the --conditions flag.

DENO_UNSTABLE_TSGO special environment variable

DENO_UNSTABLE_TSGO set to 1 enables type-checking with TypeScript's native (Go) compiler. This is equivalent to the --unstable-tsgo flag.

DENO_NO_PROMPT special environment variable

DENO_NO_PROMPT disables permission prompts on access. This is an alternative to passing --no-prompt on invocation.

DENO_JOBS special environment variable

DENO_JOBS sets the number of parallel workers used for the --parallel flag with the test subcommand. Defaults to the number of available CPUs.

DENO_KV_ACCESS_TOKEN special environment variable

DENO_KV_ACCESS_TOKEN is a personal access token used when connecting to Deno KV databases (for example via Deno.openKv or @deno/kv with a KV Connect URL).

DENO_AUDIT_PERMISSIONS special environment variable

DENO_AUDIT_PERMISSIONS audits every permission access. Set to a file path to write JSONL output, or to the literal value otel to emit OpenTelemetry log records via the configured OTel exporter.

DENO_WEBGPU_TRACE special environment variable

DENO_WEBGPU_TRACE specifies a path to a directory to output a WGPU trace to when using the WebGPU API.

DENO_WEBGPU_BACKEND special environment variable

DENO_WEBGPU_BACKEND selects the backend WebGPU will use, or a comma-separated list of backends in order of preference. Possible values are: vulkan, dx12, metal, opengl.

HTTPS_PROXY special environment variable

HTTPS_PROXY specifies the proxy address for HTTPS requests including module downloads and fetch operations.

NPM_CONFIG_REGISTRY special environment variable

NPM_CONFIG_REGISTRY specifies the URL to use for the npm registry.

NO_COLOR special environment variable

NO_COLOR when set disables color output.

NO_PROXY special environment variable

NO_PROXY is a comma-separated list of hosts which do not use a proxy for module downloads and fetch operations.

Example: Using Deno.env API for environment variables

Example showing how to use Deno.env with set, get, and has methods: Deno.env.set("FIREBASE_API_KEY", "examplekey123"); Deno.env.set("FIREBASE_AUTH_DOMAIN", "firebasedomain.com"); console.log(Deno.env.get("FIREBASE_API_KEY")); // examplekey123 console.log(Deno.env.get("FIREBASE_AUTH_DOMAIN")); // firebasedomain.com console.log(Deno.env.has("FIREBASE_AUTH_DOMAIN")); // true

Example: Using @std/dotenv load function

Example showing how to use the @std/dotenv load function: import { load } from "jsr:@std/dotenv"; const env = await load({ // optional: choose a specific path (defaults to ".env") envPath: ".env.local", // optional: also export to the process environment (so Deno.env can read it) export: true, }); console.log(env.GREETING); console.log(Deno.env.get("GREETING")); Run with: deno run --allow-read --allow-env app.ts

Example: Setting environment variables in deno.json tasks

Example showing how to set environment variables in deno.json task definitions: { "tasks": { "build:full": { "description": "Build the site with all features", "command": "BUILD_TYPE=FULL deno run main.ts" }, "build:light": { "description": "Build the site without expensive operations", "command": "BUILD_TYPE=LIGHT deno run main.ts" } } }

Quoting environment variables with spaces in .env files

When setting environment variables that contain space characters in a .env file, enclose the value in quotes. For example: MY_VAR="my value with spaces".

Give your agent this brain