Deno requires explicit permissions to protect users from scripts that might harm their system or steal data. This is a security improvement over Node.js, which allows full access by default.
Deno allows importing modules directly via URLs, simplifying dependency management and avoiding the need for a centralized package manager like npm.
const data = await Deno.readTextFile('secret.txt');
console.log(data);What error will this code produce when run with
deno run script.ts?Deno requires explicit permission flags to access files. Without --allow-read, it throws a PermissionDenied error.
const fs = require('fs');
const secret = fs.readFileSync('/etc/passwd', 'utf8');
console.log(secret);Why is this a security risk in Node.js but not in Deno by default?
Node.js scripts can read any file by default, which can expose sensitive data. Deno blocks such access unless permissions are granted.
Deno bundles common developer tools, reducing setup time and complexity compared to Node.js where you install many packages separately.
