📜  节点需要模块 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:10.100000             🧑  作者: Mango

代码示例1
// 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!"
};