FutureStack

Node.js Modules & npm Explained (CommonJS vs ESM) | Node.js Course #2

Oct 30, 2026 · 2 views

Part of Node.js & Express.js Full Course | Backend Development for Beginners to Advanced
Node.js Modules & npm Explained (CommonJS vs ESM) – Lecture 2 of the Node.js & Express Full Course, a free Node.js and Express.js tutorial for beginners. Learn Node.js modules, CommonJS vs ES modules, npm tutorial with hands-on code examples for backend JavaScript development. In Lecture 2 of this Node.js + Express course, Irfan Hayat explains how Node splits code into modules. We compare CommonJS require and module.exports with ES modules import and export, set up package.json, install packages with npm, and write npm scripts. What you'll learn • Why modules exist and how Node scopes them • CommonJS: require and module.exports • ES modules: import, export, and "type": "module" • package.json, dependencies vs devDependencies • npm install, npm scripts, and semantic versioning Chapters 00:00 Intro: why modules matter 00:55 CommonJS: require and module.exports 02:12 ES modules: import and export 03:26 CommonJS vs ESM: which to choose 04:39 npm init and package.json 05:57 Semantic versioning and using a package 07:04 Recap 07:40 Next: fs, path & os Links Altered or synthetic content: The presenter visuals and narration in this video are AI-generated/AI-assisted from the instructor's own photo and an original teaching script. All code, diagrams and teaching content are original. #NodeJS #ExpressJS #NodeJsModules