zoukankan      html  css  js  c++  java
  • Node.js入门

    首先,去http://nodejs.org 下载安装。我下的版本是0.10.28。安装很简单,下一步下一步就哦了。

    我的安装目录是C:Program Files odejs。这时使用node -v 命令查看下安装的版本

    一、helloworld

    在Node.js安装目录中新建一个文件hello.js,里面敲一行代码

    1
    console.log('hello, nodejs.') ;

    进入命令行控制台,进入到Node.js目录敲node hello.js

    控制台输出了“hello, nodejs.”

    二、web版的helloworld

    在Node.js安装目录中新建一个http.js,代码如下

    1
    2
    3
    4
    5
    6
    var http = require("http");
    http.createServer(function(request, response) {
        response.writeHead(200, {"Content-Type": "text/html"});
        response.write("Hello World!");
        response.end();
    }).listen(8000);

    在命令行中启动服务,敲 node  http.js

    然后打开浏览器地址栏输入http://localhost:8000/,看见页面上输出Hello World! 就成功了。

  • 相关阅读:
    apk反编译
    mysql 安装解读
    安卓=--确认
    安卓--界面--改变image view
    安卓--返回时,不丢失转态
    安卓--跳转
    安卓--菜单
    安卓--Toast
    设置网页上收藏夹的图标
    分帧标签
  • 原文地址:https://www.cnblogs.com/yipu/p/3774557.html
Copyright © 2011-2022 走看看