Tutorial by Examples: commonjs

CommonJS is a popular modularization pattern that's used in Node.js. The CommonJS system is centered around a require() function that loads other modules and an exports property that lets modules export publicly accessible methods. Here's an example of CommonJS, we'll load Lodash and Node.js' fs m...
Create folder. Open it in command line. Run npm install webpack -g. Create 2 files: cats.js: var cats = ['dave', 'henry', 'martha']; module.exports = cats; app.js cats = require('./cats.js'); console.log(cats); Run in command line: webpack ./app.js app.bundle.js Now in folder will be fil...

Page 1 of 1