換了Mac需要安裝noed.js和npm記錄一下
首先訪問node.js官網(https://nodejs.org/en/download/)
點擊下載完后,一路點安裝 就安裝完成了
然后打開-終端-輸入node -v 會返回當前安裝的版本號 看圖
然后在輸入 npm -v 得到
這算安裝正常了
然后在Finder中打開用戶目錄(就是Mac管理員,點開側欄打開目錄,創建一個Js文件,取名helloworld.js就可以,在js文件中輸入這些內容)
const http = require('http');
const hostname = '127.0.0.1';
const port = 1337;
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
保存成功之后,打開終端
輸入 node helloworld.js得到

然后把下面的ip地址復制到瀏覽器打開

這就配置成功了
