Mac 下 nodejs 學(xué)習(xí)
Mac 下 nodejs 學(xué)習(xí)
http://www.lxweimin.com/p/a3506384fa12
Mac +WebStorm+nodeJs+Freemarker.js的安裝與使用
http://www.lxweimin.com/p/d701a49a5032
想學(xué)習(xí) angularjs 結(jié)果看得視頻教程是在 nodejs 基礎(chǔ)上的,就決定先學(xué)一下 nodejs 以下是安裝過程,平臺是 mac。
1). Homebrew 安裝 Nodejs
$ brew install node
// 查詢安裝成功與否,可通過查詢版本:
$ node -v
2). 發(fā)起服務(wù)器
// 以下代碼可從官網(wǎng)下載
const http = require('http');
const hostname = '127.0.0.1';
const port = 1337;
var server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
})
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);});
3). 啟動服務(wù)器
node servere.js
// 改變服務(wù)器設(shè)置的值后,可在此執(zhí)行此命令,查看改變值。
最后在瀏覽器哪里訪問http://127.0.0.1:1337/
,能看到Hello World輸出;
還用nvm安裝方式