DEV Community

Cover image for node: the new Node.js protocol
Mohamed Chouichou
Mohamed Chouichou

Posted on

node: the new Node.js protocol

Node

Nodejs is open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

node: Protocol

this amazing runtime environment just launch a new protocol which allow the coder to be more sure that he include the right library and not a fake one .

Usage

Usually we use import * as fs from 'fs/promises'; for importing a library, but the problem is that sometimes we might have two libraries with the same name, one official from node.js or a core library, and the other one is written by the community and hosted by NPM, so to make sure we're using the official library, we can now use the nodeprotocol like this:
import * as fs from 'node:fs/promises';

Benefits

It may seem simple and not very useful, but this new feature can really protect you from substitution of modules, we can find module downloaded overwrite a base module, so it may be dangerous for your code.

Another advantage is that you can clearly see which core node modules you are using in your code.

Finally, I hope this helps you coding better and thank you.

Top comments (0)