Skip to main content

What is a module in Node.js?

Entry NodeJS
Quick Answer A module is a reusable piece of code in its own file. Node uses the module system to keep code organized and prevent variable name collisions. You export what you want to share (module.exports) and import what you need (require()). Every file in Node.js is automatically its own module.

Answer

A module is a separate file containing reusable code that can be imported into other files.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice