Deno blocks network, file system, environment variables, and subprocess access by default to prevent unauthorized operations. You must explicitly grant permissions to allow these.
console.log(await Deno.readTextFile("secret.txt"));
Deno throws a permission error if a script tries to access resources without the required permissions. It does not prompt or silently ignore.
--allow-net grants network access, --allow-read grants file read access. --allow-all grants all permissions but is not minimal. --allow-env and --allow-write do not grant network or read permissions.
const response = await fetch('https://example.com'); const text = await response.text(); console.log(text);
Deno requires the --allow-net flag to allow network requests. Without it, fetch calls cause a permission error.
try { const env = Deno.env.get('HOME'); console.log('Home:', env); } catch (e) { console.log('Env error:', e.name); } try { const data = await Deno.readTextFile('file.txt'); console.log('File:', data); } catch (e) { console.log('File error:', e.name); }
--allow-read grants file read access but not environment variable access. Accessing env variables without --allow-env causes PermissionDenied error.
