01. Node js Hello world
2019獨角獸企業重金招聘Python工程師標準>>>
01. Node js Hello world
環境安裝
官網http://nodejs.org/
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
上面那句話來自官網;本身就是一個網絡應用;不像有些是本地應用
進入官網,看到install 按鈕直接點去,就會自動去下載;下載完后自動去安裝;
- 確保 node 命令在Path 目錄下
-
在terminal 中運行
node -v看到 v0.10.26 類似的結果就說明安裝成功
寫個Hello World
hello_world.js
var http = require('http')http.createServer(function(req, res){res.writeHead(200,{'Content-Type':'text/plain'});res.end('Hello world\n');}).listen(1337,'127.0.0.1');console.log('Server running at http://127.0.0.1');運行
node hello_world.js瀏覽器輸入
http://127.0.0.1:1337真正的Hello world 在hello_world.js中如下:
console.log('Hello world')運行:
node hello_world.js其實還有更簡單的
直接在終端輸入:
node就出現命令行界面, 直接輸入
console.log('Hello world')以上是入門,基礎;
轉載于:https://my.oschina.net/jiemachina/blog/201727
總結
以上是生活随笔為你收集整理的01. Node js Hello world的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实现图片本地化 ServiceWorke
- 下一篇: 微信小程序+ColorUI