'Node.js'

Installation

'GNU/Linux' ('Debian')

(From https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions).

The package available under Debian are too old (version 0.10). So, we install it from another source.

  • curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -,
  • sudo apt-get install -y nodejs (aptitude can be used instead of apt-get).

To build native addons :

  • sudo apt-get install -y build-essential (aptitude can also be used instead of apt-get).

This is not specific to node.js, so it may be already installed.

Others ('macOS'/'Windows')

Simply use the installer on http://nodejs.org/.

Common

To develop native addons :

  • npm install -g node-gyp.

Misc

About writing Node.js C++ components.

Home page : http://nodejs.org/

Download : https://nodejs.org/en/download/current/ ; click the All download options link.

Get the binary package, not the installer (should be more convenient for developing, and also switching between 32 and 64 bits versions), and also the source one (at the bottom of the page). The two packages can be merged ; there would be three conflicting files (README.md, CHANGELOG.md and LICENSE), but they are not essential.

Don't put Window drive (C:\, for example) in the directory in binding.gyp, or you will have multiple target warning when building the addon with make, due to the fact that : is a separator character for make.

'uv'

uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb) allows to launch work_cb in another thread. uv_after_work_cb is launched once exited from work_cb.

You can absolutely not access any of V8 data from work_cb (but you can from uv_after_work_cb).
The size of the thread pool can be defined with the UV_THREADPOOL_SIZE environment variable. Default is 4, and maximum is 128.

This value can also be can changed from within node by using process.env.UV_THREADPOOL_SIZE=….

It seems possible to launch uv_queue_work(…) from work_cb.