系统:Windows 7 VsCode:1.51 Node.js:10.15.3
Part 1:场景说明

Part 2: 代码

common_func.js
exports.test1 = function add(a, b) {
let c = a+b;
return c;
}
exports.test2 = function minus(a, b) {
let c = a-b;
return c;
}example_1.js
let fx= require ('./common_func');
const a = 1
const b = 2
let c = fx.test1(a, b)
console.log(c)
c = fx.test2(a, b)
console.log(c)代码截图

运行结果

Part 3:部分代码说明

node.js而不是浏览器,在导出引用这块是有点区别的exports.test1require的方式,引用了整个模块let fx= require ('./common_func')。再通过fx.test1这样的方式引用需要的函数