在 Node.js 中使用模块系统来引用其他的代码文件。使用 require
函数来引入模块,然后使用模块的接口,如方法和变量。
举个例子:
假设有一个文件叫 myModule.js
,包含以下代码:
exports.hello =function() {
console.log("Hello World");
};
在 Node.js 中使用模块系统来引用其他的代码文件。使用 require
函数来引入模块,然后使用模块的接口,如方法和变量。
举个例子:
假设有一个文件叫 myModule.js
,包含以下代码:
exports.hello =function() {
console.log("Hello World");
};