【发布时间】:2020-05-14 09:19:51
【问题描述】:
我正在尝试导出一个 NPM 模块以在没有包名的情况下使用它。
这是导出模块的常用方法:
function hello(){
console.log("hello");
}
module.exports.hello = hello;
我们是这样使用的:
const h = require("hello");
h.hello();
但我想在没有 h 变量的情况下使用它。所以我想像这样使用这个模块:
require("hello");
hello();
我怎样才能像这样导出这个模块?
【问题讨论】:
标签: javascript node.js npm node-modules