Meta tags:
description= Read and configure environment variables in Bun, including automatic .env file support;
Headings (most frequently used words):
environment, variables, runtime, env, transpiler, system, cache, documentation, index, on, this, page, setting, manually, specifying, files, disabling, automatic, loading, quotation, marks, reading, typescript, configuring, bun, caching, get, started, core, file, module, http, server, networking, data, storage, concurrency, process, interop, tooling, utilities, standards, compatibility, contributing, expansion, dotenv, disable, the, what, does, it,
Text of the page (most frequently used words):
bun (57), env (51), the (34), variables (19), and (17), file (17), #process (16), environment (16), foo (14), files (12), run (12), cache (11), this (10), #disable (10), runtime (10), for (9), string (9), dev (8), set (8), hello (8), platform (7), page (7), use (7), output (7), transpiler (7), with (7), automatically (6), you (6), also (6), typescript (6), system (6), bun_runtime_transpiler_cache_path (5), using (5), directory (5), windows (5), then (5), bar (5), helloworld (5), loading (5), documentation (4), shell (4), transpiled (4), when (4), all (4), specific (4), crash (4), are (4), disabled (4), fetch (4), bun_config_verbose_fetch (4), node (4), reads (4), secret (4), dotenv (4), can (4), toml (4), index (4), automatic (4), package (4), copy (4), larger (3), than (3), caches (3), does (3), any (3), even (3), running (3), makes (3), load (3), caching (3), example (3), macos (3), other (3), both (3), console (3), watch (3), http (3), install (3), color (3), no_color (3), curl (3), production (3), compatibility (3), configure (3), awesome (3), your (3), module (3), print (3), api_token (3), read (3), world (3), expansion (3), bunfig (3), scripts (3), json (3), cross (3), workers (2), source (2), what (2), empty (2), like (2), docker (2), content (2), into (2), clis (2), faster (2), command (2), line (2), hot (2), bun_options (2), uploading (2), reports (2), report (2), default (2), telemetry (2), not (2), sent (2), add (2), auto (2), do_not_track (2), bun_config_no_clear_terminal_on_reload (2), requests (2), defaults (2), connection (2), ansi (2), force_color (2), unset (2), linux (2), tmp (2), which (2), written (2), headers (2), works (2), useful (2), debugging (2), variable (2), name (2), node_tls_reject_unauthorized (2), these (2), behavior (2), configuring (2), property (2), interface (2), get (2), undefined (2), meta (2), import (2), reading (2), postgres (2), db_user (2), db_password (2), db_host (2), db_port (2), reference (2), quotes (2), quotation (2), marks (2), disabling (2), manually (2), specifying (2), programmatically (2), node_env (2), development (2), following (2), exec (2), solution (2), test (2), setting (2), contributing (2), apis (2), data (2), cookies (2), server (2), search (2), built, hosted, mintlify, developer, powered, youtube, discord, github, next, previous, raise, issue, suggest, edits, yes, was, helpful, cached, extension, pile, sourcemap, ephemeral, filesystems, images, global, shared, across, projects, addressable, never, contains, duplicate, entries, safe, delete, time, while, prepends, arguments, execution, behave, uploads, enabled, though, plan, some, clear, reload, true, sets, maximum, number, concurrent, lower, rate, limits, issues, 256, bun_config_max_http_requests, forced, occasionally, requires, store, intermediate, assets, during, bundling, operations, temporary, private, tmpdir, that, log, url, method, request, response, equivalent, except, without, disables, ssl, certificate, validation, testing, but, very, hesitant, introduced, keeps, description, aspects, its, declaration, project, globally, adds, declare, autocompletion, tell, treat, non, optional, merging, whatever, properties, typed, lots, more, lines, aaaaaa, foobar, stuff, baz, currently, exposes, aliases, current, from, unnecessary, expand, escape, backslash, db_name, db_url, 5432, localhost, constructing, strings, compound, values, previously, defined, expands, supports, double, single, template, literal, backticks, passed, still, false, pipelines, where, want, rely, solely, build, def, abc, src, flag, overrides, loads, them, assigning, app, called, through, powershell, cmd, local, depending, value, listed, order, increasing, precedence, provides, idiomatic, ways, write, parts, including, support, license, bindgen, building, benchmarking, roadmap, web, globals, standards, utils, semver, glob, hashing, image, htmlrewriter, jsonl, json5, markdown, yaml, secrets, csrf, protection, utilities, compiler, ffi, api, interop, tooling, cron, webview, spawn, concurrency, redis, sqlite, sql, archive, binary, streams, storage, dns, udp, tcp, websockets, networking, metrics, error, handling, tls, routing, router, plugins, jsx, resolution, types, repl, mode, core, create, init, quickstart, installation, welcome, started, feedback, blog, guides, runner, bundler, manager, navigation, home, skip, main, discover, available, pages, before, exploring, further, complete, docs, llms, txt,
Text of the page (random words):
environment variables bun documentation index fetch the complete documentation index at docs llms txt use this file to discover all available pages before exploring further skip to main content bun home page search k install bun search navigation process system environment variables runtime package manager bundler test runner guides reference blog feedback get started welcome to bun installation quickstart typescript typescript 6 and 7 bun init bun create core runtime bun runtime watch mode debugging repl bunfig toml file module system file types module resolution jsx auto install plugins file system router http server server routing cookies tls error handling metrics networking fetch websockets tcp udp dns data storage cookies file i o streams binary data archive sql sqlite s3 redis concurrency workers process system environment variables shell spawn webview cron interop tooling node api ffi c compiler transpiler utilities csrf protection secrets console toml yaml markdown json5 jsonl htmlrewriter image hashing glob semver color utils standards compatibility globals bun apis web apis node js compatibility contributing roadmap benchmarking contributing building windows bindgen license on this page setting environment variables manually specifying env files disabling automatic env loading quotation marks expansion dotenv reading environment variables typescript configuring bun runtime transpiler caching disable the runtime transpiler cache what does it cache process system environment variables copy page copy page read and configure environment variables in bun including automatic env file support copy page copy page bun reads your env files automatically and provides idiomatic ways to read and write your environment variables programmatically you can also configure parts of bun s runtime behavior with bun specific environment variables setting environment variables bun reads the following files automatically listed in order of increasing precedence env env production env development env test depending on the value of node_env env local env foo hello bar world you can also set variables on the command line linux macos windows foo helloworld bun run dev using cmd set foo helloworld bun run dev using powershell env foo helloworld bun run dev cross platform solution with windows for a cross platform solution use bun shell for example through bun exec bun exec foo helloworld bun run dev on windows package json scripts called with bun run automatically use the bun shell so the following is also cross platform package json scripts dev node_env development bun watch app ts or set them programmatically by assigning a property to process env process env foo hello manually specifying env files the env file flag overrides which env files bun loads it works both when running a file with bun and when running package json scripts bun env file env 1 src index ts bun env file env abc env file env def run build disabling automatic env loading use no env file to disable bun s automatic env file loading for example in production or ci cd pipelines where you want to rely solely on system environment variables bun run no env file index ts you can also disable it in bunfig toml bunfig toml disable loading env files env false files passed with env file still load even when default loading is disabled quotation marks bun supports double quotes single quotes and template literal backticks env foo hello foo hello foo hello expansion bun automatically expands environment variables so you can reference previously defined variables env foo world bar hello foo process env bar helloworld this is useful for constructing connection strings or other compound values env db_user postgres db_password secret db_host localhost db_port 5432 db_url postgres db_user db_password db_host db_port db_name to disable expansion escape the with a backslash env foo world bar hello foo process env bar hello foo dotenv bun reads env files automatically so dotenv and dotenv expand are unnecessary reading environment variables read the current environment variables from process env process env api_token secret bun also exposes these variables as bun env and import meta env both aliases of process env bun env api_token secret import meta env api_token secret to print all currently set environment variables run bun print process env bun print process env baz stuff foobar aaaaaa lots more lines typescript in typescript all properties of process env are typed as string undefined bun env whatever string undefined to get autocompletion and tell typescript to treat a variable as a non optional string use interface merging declare module bun interface env awesome string add this declaration to any file in your project it globally adds the awesome property to process env and bun env process env awesome string configuring bun bun reads these environment variables to configure aspects of its behavior name description node_tls_reject_unauthorized node_tls_reject_unauthorized 0 disables ssl certificate validation useful for testing and debugging but be very hesitant to use it in production node js introduced this variable bun keeps the name for compatibility bun_config_verbose_fetch if bun_config_verbose_fetch curl then fetch requests log the url method request headers and response headers to the console this also works with node http bun_config_verbose_fetch 1 is equivalent to bun_config_verbose_fetch curl except without the curl output bun_runtime_transpiler_cache_path the runtime transpiler caches the transpiled output of source files larger than 4 kb which makes clis using bun load faster if bun_runtime_transpiler_cache_path is set the cache is written to that directory if it is set to an empty string or the string 0 caching is disabled if it is unset the cache is written to the platform specific cache directory tmpdir bun occasionally requires a directory to store intermediate assets during bundling or other operations if unset defaults to the platform specific temporary directory tmp on linux private tmp on macos no_color if no_color 1 then ansi color output is disabled force_color if force_color 1 then ansi color output is forced on even if no_color is set bun_config_max_http_requests sets the maximum number of concurrent http requests sent by fetch and bun install defaults to 256 lower it if you run into rate limits or connection issues bun_config_no_clear_terminal_on_reload if bun_config_no_clear_terminal_on_reload true then bun watch does not clear the console on reload do_not_track disable uploading crash reports to bun report on crash on macos windows crash report uploads are enabled by default other telemetry is not sent though we plan to add some if do_not_track 1 then auto uploading crash reports and telemetry are both disabled bun_options prepends command line arguments to any bun execution for example bun_options hot makes bun run dev behave like bun hot run dev runtime transpiler caching for files larger than 4 kb bun caches transpiled output into bun_runtime_transpiler_cache_path or the platform specific cache directory this makes clis using bun load faster the cache is global and shared across all projects and it is content addressable so it never contains duplicate entries it is safe to delete at any time even while a bun process is running disable this cache when using ephemeral filesystems like docker bun s docker images disable it automatically disable the runtime transpiler cache to disable the runtime transpiler cache set bun_runtime_transpiler_cache_path to an empty string or the string 0 bun_runtime_transpiler_cache_path 0 bun run dev what does it cache it caches the transpiled output of source files larger than 4 kb the sourcemap for the transpiled output of the file cached files use the pile extension was this page helpful yes no suggest edits raise issue workers previous shell next i x github discord youtube powered by this documentation is built and hosted on mintlify a developer documentation platform
|