Need Assistance?

support@tutorialshub.in

Modules and npm

ES modules

Node.js Free Lesson
5 min read
ADVERTISEMENT

Modern Node.js also supports standard ES modules with import and export.

You may encounter both module styles in real projects. Learn to recognize the project's configured module system before mixing syntax.

Deep dive

Module configuration

ES module behavior depends on the project's package configuration and file conventions. Read the existing project's package.json before changing module syntax.

Important distinction

import/export is JavaScript's standardized module syntax. CommonJS require/module.exports is Node's older module system. Both are widely encountered in real projects.

ADVERTISEMENT