Deno 2.0, a planned major release of the Deno runtime for JavaScript, TypeScript, and WebAssembly and rival to Node.js, is now available as a release candidate. The new version brings two big changes to global variables, new features to improve dependency management, changes to the permission system, and more.
The Deno 2.0 release candidate (RC) was unveiled September 19. Developers can try it out by running deno upgrade
followed by deno upgrade rc
in their terminal.
The Deno 2.0 RC includes everything anticipated in the final release of Deno 2.0. Two major changes in the release are the removal of the window
global variable and the addition of Node.js’s process
. DenoLand, the maker of Deno, said the window
global was introduced in Deno 1.0 to make Deno as browser-compatible as possible. But this global variable was a source of problems, leading to bugs in libraries that otherwise would work in Deno. In contrast, the process global has been widely requested. With the addition of process
, developers can expect more code originally written for the rival Node.js runtime to work with no changes in Deno. However, DenoLand still encourages users to prefer explicit imports, so has added a new no-process-global lint rule to provide hints and quick fixes in the editor to use an import statement instead.
To improve dependency management, Deno 2.0 introduces a deno add
subcommand to handle specifiers with a subpath. In addition, if a project contains a package.json file, Deno will prefer adding npm:
dependencies to package.json rather than deno.json
. Developers can add “dev dependencies” to package.json using the --dev
flag. Also with Deno 2.0, deno install
now supports the --entrypoint
flag, which allows for installing all dependencies from a given module. And a new deno remove
subcommand has been added to quickly remove some dependencies. Deno 2.0 also ships with a more concise lockfile format (v4) to minimize diffs when updating dependencies and ensuring reproducible builds. Additionally, Deno has improved error messaging, providing hints for common issues such as incorrectly formatted relative import paths or missing dependencies when using “bare specifiers.” DenoLand said the updates collectively streamline the process of managing dependencies in Deno projects, making it more intuitive and aligned with modern development workflows.
The Deno permission system also gets attention in Deno 2.0. With version 2.0, a lack of Deno permissions now raises the Deno.errors.Notcapable
error instead of Deno.errors.PermissionDenied
, making it easier to discriminate between OS-level errors and Deno errors. Also, the permissions check for the Deno.mainModule
API, which gives a pull path to the main module, has been relaxed and no longer requires full --allow-read
permission. This also applies to the process.argv
API. It also is now possible to grant permissions for reading and writing files that contain commas in the file name.
Other new features and changes in Deno 2.0:
- Several APIs have been stabilized, including WebGPU APIs no longer requiring an
--unstable-webgpu
flag. Error messages also have been improved. - For command line interfaces, support has been removed for the
deno bundle
anddeno vendor
commands. - Import assertions are no longer available in Deno 2.0, having been replaced by import attributes.
- For Node.js and NPM compatibility, improvements have been made to make transition to ECMAScript (ES) modules easier. DenoLand views ES modules as the future of JavaScript.
- Deno 2.0 ships with TypeScript 5.6.