Follow us
Breaking
Tech News

Deno 2.2 simplifies TypeScript servers with native npm support

Deno 2.2 enhances TypeScript server development with native npm compatibility and a secure permission model. The runtime offers significant performance gains, with deno install running up to 90% faster than npm when using a hot cache.

Share

Security and TypeScript

Deno runs code with zero permissions by default. You must explicitly grant access to the network via --allow-net or the filesystem via --allow-read. This design blocks supply chain attacks that attempt to access unexpected files. If you want to run a server on port 8000, you use deno run --allow-net=:8000 server.ts. Deno handles TypeScript. Ryan Dahl created Deno using V8, Rust, and Tokio. Deno runs 20% slower than earlier benchmarks indicated because the runtime disabled V8 pointer compression to prevent users from exceeding the 4GB heap limit.

You can restrict permissions to specific resources, such as deno run --allow-read=./data server.ts. Other common flags include --allow-env for environment variables, --allow-run for subprocesses, --allow-sys for operating-system information, and --allow-ffi for native libraries. Deno maintains security by design, unlike Node.js which relies on dependency auditing and security scanning tools. This permission model reduces attack surface area significantly. Deno provides a lightweight 10MB executable. Deno uses a Promise-based API. Deno’s permission model applies to remote scripts as well. You can also use the --allow-all flag if you trust a dependency completely. Deno remains the best choice for developers prioritizing a secure, zero-config environment.

Package management

Deno 2 offers backwards compatibility with Node.js and npm. It understands package.json and node_modules for existing projects. You can import any of the 2 million npm modules using npm:specifiers. Use deno add. This command adds packages to your package.json or deno.json. deno install works much faster than npm. It runs 15% faster than npm with a cold cache and 90% faster with a hot cache. You probably already know the pain of managing a massive node_modules folder. Deno provides a way to avoid that clutter by caching dependencies globally. If you have a package.json, deno install creates a node_modules folder.

Deno 2 also supports JSR, a modern registry for sharing JavaScript libraries. JSR handles module loading intricacies and supports TypeScript natively. You can also use deno task to run scripts from a package.json file. Deno 2 works with frameworks like Next.js, Astro, Remix, Angular, SvelteKit, and QwikCity. For larger projects, a dependency manifest like deno.json simplifies management. You can also use import maps to create aliases for cleaner imports. Deno handles private npm registries through .npmrc files. Deno 2 provides workspaces and monorepo support, which allows you to manage multiple packages with separate dependencies and individual configuration settings within a single, cohesive, and highly efficient, unified, and scalable project structure for your entire development team.

Integrated tooling

Deno includes a formatter, linter, test runner, and documentation generator in one toolchain. deno fmt works 10x to 20x faster than Prettier. deno lint runs in milliseconds. Deno’s standard library includes dozens of audited modules like @std/testing and @std/http. Deno 2.1 introduces an LTS channel that provides critical bug fixes for six months. For enterprises, Deno offers a program with priority support and direct access to engineers.

deno fmt now formats HTML, CSS, and YAML. deno test supports running tests written using node:test. deno compile creates standalone executables. deno serve runs HTTP servers across multiple cores in parallel. deno bench supports critical sections for more precise measurements. deno doc generates documentation from JSDoc comments. Deno removes the tooling complexity that often frustrates TypeScript developers. Unlike Node.js which requires you to combine ESLint, Prettier, Jest, and Webpack, Deno delivers everything in one package. Deno handles everything. Will the migration costs of rebuilding deployment pipelines ever decrease?

Share

Technewsdaily

Senior tech writer covering AI, gadgets and cybersecurity. Breaking down the news that matters, every day.