Deno already supports NPM modules

deno npm

The platform is being developed by Ryan Dahl, creator of Node.js.

Recently the news of the release of the new version of the Deno 1.28 framework was released, which enables the execution of stand-alone JavaScript and TypeScript applications that can be used to create controllers that run on the server.

Deno was created to provide users with a more secure environment and eliminate misconceptions in the Node.js architecture. To improve security, the binding around the V8 engine is written in Rust, which prevents many vulnerabilities that arise due to low-level memory handling.

To process requests in non-blocking mode, the Tokio framework, also written in Rust, is used. Tokio allows you to create high-performance applications based on event-driven architecture, supporting multithreading and processing network requests asynchronously.

Some of the features Deno's main ones are the following:

  • Built-in TypeScript language support in addition to JavaScript. To check types and generate JavaScript, the regular TypeScript compiler is used, which leads to a drop in performance compared to JavaScript parsing in V8.
  • The runtime comes in the form of a single stand-alone executable (“deno”). To run applications using Deno, you simply download an executable file for your platform, about 30MB in size, which has no external dependencies and does not require any special installation on your system.
  • Efficient application processing of network requests via HTTP, the platform is designed to build high-performance network applications
  • The ability to create universal web applications that can run both in Deno and in a regular web browser
  • The presence of a standard set of modules, the use of which does not require linking to external dependencies.
  • Modules from the standard collection have been additionally audited and tested for compatibility
  • The package includes a built-in dependency inspection system ("deno info" command) and a code formatting utility (deno fmt).
  • All application scripts can be combined into one JavaScript file.

Main news of Deno 1.28

The key change in the new version is the stabilization of compatibility with packages hosted in the NPM repositoryWhich allows Deno to use more than 1,3 million modules built for the Node.js platform. For example, Deno-based applications can now use persistent data access modules like Prisma, Mongoose, and MySQL, as well as front-end frameworks like React and Vue.

Some NPM modules are still incompatible with Deno, for example, due to bindings to specific Node.js environments, such as the package.json file. It is also not possible to use the "deno compile" command with NPM modules. Future releases are planned to address these incompatibilities and limitations.

The module system Deno legacy ECMAScript and Web API module model remain the same, and Deno's familiar URL-based loading scheme is used to import NPM modules.

Using NPM packages in Deno is much easier than in Node.js, because there is no need to pre-install modules (modules are installed when the application is started for the first time), the package.json file is not used and the node_modules directory is not used, is used by default (modules are cached in the shared directory, but it is possible to revert the previous behavior with the "--node-modules-dir" option).

applications based on NPM retain the ability to use access control mechanisms, Deno isolation and activation for advanced functions that affect security. To counter attacks via questionable dependencies, Deno blocks by default all attempts to access the system from dependencies and displays a warning about detected problems. For example, when the module attempts to write to /usr/bin/, a confirmation prompt will be displayed for this operation:

Non-NPM related enhancements in the new version include V8 engine upgrade for version 10.9, automatic detection of files with locks, stabilization of Deno.bench(), Deno.gid(), Deno.networkInterfaces(), Deno.systemMemoryInfo( ), and the Deno APIs. .uid(), adding a new unstable API Deno.Command() to execute commands (universal replacement for Deno.spawn, Deno.spawnSync and Deno.spawnChild).

Finally it is worth mentioning that Like Node.js, Deno uses the V8 JavaScript engine., which is also used in Chromium-based browsers. At the same time, Deno is not a fork of Node.js, but a new project built from scratch. The project's code is distributed under the MIT license and there are ready-made builds for Linux, Windows and macOS.

If you are interested in knowing more about it, you can consult the following link.


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.