nodejs自學.jsnode
function hello(){
console.log("hello world");
}app
function s(){
console.log("this is a ew");
}ui
function add(a, b){
return a+b;
}this
exports.hello = hello;//留出接口
exports.s = s;
exports.add = add;spa
test.js接口
//加載模塊
var app = require("./nodejs自學");//./表示當前目錄,也能夠填"./nodejs自學.js"
app.hello();
app.s();
console.log(app.add(1,3));io
在終端中 node test.js console
結果:function
hello worldtest
this is a ew
4