Answers for "npm can i use my modules without specifying the path"

7

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!"
};
Posted by: Guest on May-25-2020
0

npm can i use my modules without specifying the path

npm install --save ../path/to/mymodule
Posted by: Guest on October-22-2020

Code answers related to "npm can i use my modules without specifying the path"

Code answers related to "Javascript"

Browse Popular Code Answers by Language