windows环境下安装

  1.   首先官方下载地址http://www.nodejs.org/download/下载对应版本的NodeJs
  2.   双击安装对应的目录下如F:\mySoft\nodeJs,可以看到如下目录
    NodeJs环境安装初探
  3. 打开cmd窗口,cd到F:\mySoft\nodeJs
  4. 输入npm install express

       npm install mysql

       npm install http  等命令,就把所依赖的js目录引用的工程中了

 

5. 简单的demo

//helloworld.js
var sys = require("sys"),  
     http = require("http");  
     http.createServer(function(req, res) {  
     setTimeout(function () {
             res.writeHeader(200, {"Content-Type": "text/plain"});
             res.write("Hello,World!");
             res.end();
         }, 2000);
     }).listen(8000);
 sys.puts("Server running at http://localhost:8000/");  

 

保存在F:\mySoft\nodeJs 下,创建为文件名helloworld.js

在cmd中输入 node helloworld.js

然后就浏览器中输入http://localhost:8000/就可以看到

Hello,World!

打印出来了

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-01-07
  • 2021-05-08
  • 2021-10-30
  • 2021-06-29
猜你喜欢
  • 2021-12-09
  • 2021-12-16
  • 2022-12-23
  • 2021-12-16
  • 2022-01-13
  • 2021-06-07
相关资源
相似解决方案