var express = require('express'), app = express(), path = require('path'), os = require('os'), port = 3002; var htmlPath = path.join(__dirname, "public"); app.use(express.static(htmlPath)); //==============启动服务================== app.listen(port, function () { //console.log("Example app listening on port " + port); console.log("native browse: http://localhost:" + port); console.log("ip browse: http://" + getLocalIP() + ":" + port); }); // console.log(os.networkInterfaces()); function getLocalIP() { //获取IP地址 const WLAN = ((os.networkInterfaces()).WLAN)[1]; return WLAN.address; }