Node js new protocol
Hey readers! So there is a new change in Node js which has been there for a while, that is the introduction of a new protocol in Node js. Do check out codedamn’s YouTube channel for more amazing videos and update.
const fetch= require(‘fetch’);
mode_modules-> ../node_modules-> global modules folder
Similarly for fs which is a file system module if it had any malicious module or anything installed inside the node module then this fs would be imported as a module instead of the official one which in most cases we don’t want that. So to import an official module do something like this.
const fs= require(‘node:fs’);
console.log(fs) // you get the complete log of the module
This protocol will work automatically for Node 16 and above.
- Built-in Node module is imported
- No risk of overriding node modules
const fs= require(‘node:fs/promise’);
If you do something like this then it will import the promised version of this module.
If you like this blog then do check out this video on the codedamn YouTube channel with an in-depth explanation. If you have any queries or suggestions, do let us know in the comments! Check out the courses on Codedamn and practice coding in the Codedamn playgrounds.
Free money-back guarantee
Unlimited access to all platform courses
100+ practice projects included
ChatGPT Based Instant AI Help (Jarvis)
Structured Node.js Full-Stack Roadmap To Get A Job
Exclusive community for events, workshops
Sharing is caring
Did you like what Vishnupriya wrote? Thank them for their work by sharing it on social media.
- Reactjs fetch API example
- How to setup Redux with React