-
Node JS installation from official site nodejs.org - use only LTS versions
-
Use terminal / command prompt to check installation :
node -v
npm -v
-
VS Code installation directly from code.visualstudio.com site
-
Use VS code terminal to run commands
-
Node REPL interface can be used directly by typing
node
in terminal / command prompt . Use Ctrl+D to exit interface. Use CTRL+C to exit terminal -
Running any JavaScript file from node using
node filename.js
-
Modules are basic containers in Node/JavaScript system. 1 file can be one module in Javascript.
-
Two type of Module Systems in node JS are - CommonJS module and ES Modules.
- CommonJS Module
//lib.js
exports.sum = function(){}
//index.js
const module = require('./lib.js')
module.sum();
- ES Module
//lib.js
export {sum}
//index.js
import {sum} from './lib.js'