= NodeJS =
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.

[[http://www.nodejs.org/]]

== SlackBuild Slackware64 14.0 ==
 * su
 * cd /tmp
 * wget http://slackbuilds.org/slackbuilds/14.0/network/node.tar.gz
 * tar xvzf node.tar.gz
 * cd node
 * wget http://nodejs.org/dist/v0.10.12/node-v0.10.12.tar.gz
 * ./node.SlackBuild 
 * installpkg /tmp/node-0.10.12-x86_64-1_SBo.tgz 

Package 64 bit: [[attachment:node-0.10.12-x86_64-1_SBo.tgz]]

== node-gyp ==
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js.

https://github.com/TooTallNate/node-gyp

=== Install with npm ===
su
npm install -g node-gyp
node-gyp

=== Hello world gyp ===
Based on https://github.com/joyent/node/tree/master/test/addons/hello-world
 * cd /tmp/ 
 * nano test.js
 * nano binding.cc
 * nano binding.gyp
 * node-gyp configure #The configure step looks for the binding.gyp file in the current directory
 * node-gyp build # gave an error building !

Based on https://github.com/rvagg/node-addon-examples
 * nano binding.gyp 
{{{
{
  "targets": [
    {
      "target_name": "hello",
      "sources": [ "hello.cc" ]
    }
  ]
}
}}}
 * nano hello.cc
{{{#!highlight cpp
#include <node.h>
#include <v8.h>

using namespace v8;

Handle<Value> Method(const Arguments& args) {
  HandleScope scope;
  return scope.Close(String::New("world"));
}

void init(Handle<Object> exports) {
  exports->Set(String::NewSymbol("hello"),
      FunctionTemplate::New(Method)->GetFunction());
}

NODE_MODULE(hello, init)
}}}
 * nano hello.js
{{{#!highlight javascript
var addon = require('./build/Release/hello');

console.log(addon.hello()); // 'world'
}}}
 * node hello.js