zoukankan      html  css  js  c++  java
  • ubuntu下安装node.js

    1,首先安装一下依赖包

    sudo apt-get install g++ curl libssl-dev apache2-utils

    2,安装必备的git

    sudo apt-get install git-core

    3,通过git下载node

    git clone git://github.com/ry/node.git

    4,解压

    wget http://nodejs.org/dist/node-v0.1.96.tar.gz
    gunzip node-v0.1.96.tar.gz
    tar -xf node-v0.1.96.tar

    5,安装

    cd node
    ./configure
    make
    sudo make install

    6,简单的小例子

    var http = require('http'); 
    var url = ('ajax.googleapis.com') 
    var google = http.createClient(80, url); 
    var text = "Hello World from node!"; 
    var requestUrl = '/ajax/services/language/translate?v=1.0&q=' + 
                     escape(text) + '&langpair=en%7Cfr' 
    var request = google.request('GET', requestUrl, 
    {"host": "ajax.googleapis.com"}); 
    request.end(); 
    request.addListener('response', function (response) { 
    var body = ''; 
      response.addListener('data', function (chunk) { 
        body += chunk; 
    }); 
        response.addListener("end", function() { 
    var jsonData = JSON.parse(body); 
          console.log(jsonData.responseData.translatedText); 
    }) 
    });

    来源:http://www.sevenmike.com/2011/05/26/install-node-js-in-ubuntu/

  • 相关阅读:
    基于JavaMail开发邮件发送器工具类
    微服务架构
    图像识别
    Manacher
    左偏树
    虚树
    动态树(Link-Cut Tree)
    Splay
    扩展中国剩余定理(EXCRT)
    K-D树
  • 原文地址:https://www.cnblogs.com/walkerwang/p/2358931.html
Copyright © 2011-2022 走看看