美文网首页
2. Hello World,我的第一个程序~^^

2. Hello World,我的第一个程序~^^

作者: 尛雅 | 来源:发表于2016-04-13 11:00 被阅读54次

1. 新建测试程序(官网提供):

`consthttp=require('http')

consthostname='127.0.0.1'

constport=3000

constserver=http.createServer((req,res)=>{

res.statusCode=200

res.setHeader('Content-Type','text/plain')res.end('Hello World\n')

})

server.listen(port,hostname,()=>{

console.log(`Server running at http://${hostname}:${port}/`)

});`


2. 打开nodejs cmd 打开nodejs环境

3. 在浏览器里输入127.0.0.1:3000

 打开专属你的第一个nodejs程序~hello world~

相关文章

网友评论

      本文标题:2. Hello World,我的第一个程序~^^

      本文链接:https://www.haomeiwen.com/subject/kysilttx.html