commonjs 暴露模块的实例 index.js const greeting = require('./src/greeting') greeting.hello() //或者使用es6 解构 //const {hello} = require('./src/greeting') //hello() hello.js const hello = ()=>{ console.log("hello"); } module.exports.hello = hello