js require a file code example
Example 1: Node require module
const Globals = require.main.require("./globals.js");
const YourCustomModule = require("./yourmodule.js");
console.log(YourCustomModule.message);
module.exports = {
message: "Hello World!",
otherData: "Hello Grepper!"
};
Example 2: javascript using another js file
export function hello() {
return "Hello";
}
import {hello} from 'module';
let val = hello();
Example 3: npm can i use my modules without specifying the path
npm install --save ../path/to/mymodule