Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Node require module

// Use require.main.require to get a module from the root folder.
const Globals = require.main.require("./globals.js");
const YourCustomModule = require("./yourmodule.js");

console.log(YourCustomModule.message);

// --- yourmodule.js ---
module.exports = {
	message: "Hello World!",
	otherData: "Hello Grepper!"
};
 
PREVIOUS NEXT
Tagged: #Node #require #module
ADD COMMENT
Topic
Name
8+2 =