1In the package.json file add "type" : "module", . Adding this enables ES6 modules.
2
3//This will enable you to use import statements without any errors
1import defaultExport from "module-name";
2import * as name from "module-name";
3import { export1 } from "module-name";
4import { export1 as alias1 } from "module-name";
5import { export1 , export2 } from "module-name";
6import { foo , bar } from "module-name/path/to/specific/un-exported/file";
7import { export1 , export2 as alias2 , [...] } from "module-name";
8import defaultExport, { export1 [ , [...] ] } from "module-name";
9import defaultExport, * as name from "module-name";
10import "module-name";
11var promise = import("module-name");
12
1// To import our own Node JS module
2
3var arthmetic = require("arthmetic");
4
5//To import existing Node JS Module
6//1. Import Node JS “express” module;
7
8var arthmetic = require("express");
9
10//2. Import Node JS “mongoose” module;
11
12var mongoose = require("mongoose");
13
14//This require() call is similar to import statement in Java.
15// We use import import statement to import a package, class, interface etc. into another class or interface