What is deno.json: Configuration File Explained
deno.json file is a configuration file used by Deno to store project settings like permissions, import maps, and compiler options. It helps Deno run your code with consistent settings without typing long commands every time.How It Works
The deno.json file acts like a control panel for your Deno project. Instead of typing many options in the command line each time you run your code, you put them in this file once. Then, Deno reads this file automatically and applies those settings.
Think of it like setting your favorite radio stations on presets. You don’t have to dial the frequency every time; you just press a button. Similarly, deno.json presets your project’s permissions, import maps, and compiler options so your workflow is smoother and less error-prone.
This file is written in JSON format, which is easy to read and edit. It can include settings like which files to allow access to, how to resolve module paths, and how to compile TypeScript code.
Example
This example shows a simple deno.json file that sets permissions, an import map, and compiler options.
{
"permissions": {
"read": true,
"net": false
},
"importMap": "import_map.json",
"compilerOptions": {
"strict": true
}
}When to Use
Use deno.json when you want to keep your Deno project settings organized and reusable. It is especially helpful for projects that require specific permissions or compiler settings to run correctly.
For example, if your project needs to read files but not access the internet, you can set that once in deno.json. This avoids mistakes like forgetting permissions or typing long commands repeatedly.
It also helps teams share consistent settings, so everyone runs the project the same way without confusion.
Key Points
- Centralizes project settings: permissions, import maps, compiler options.
- Reduces command line typing: run Deno with preset configurations.
- Improves consistency: useful for teams and repeated runs.
- Written in JSON: easy to read and edit.