Blog of Raivo Laanemets

Stories about web development, freelancing and personal computers.

Node.js and io.js convergence to version 4

io.js has been merged back to Node.js. The result is the version 4 of Node.js. This has been covered in many recent articles and also in Node Weekly/JavaScript Weekly mailing lists. I have already upgraded my dev environment to the new version and the most of my projects seem to work. While pure JavaScript packages all work, there are some issues with native addons.

Native addons broken

All native addons using NAN version < 2.x are broken. There is a meta-issue on this on the Node.js GitHub repo. Addons using NAN pre 2.x version were already broken on io.js version 3 too but the version 3 did not become widely used before the merge. I maintain the fast-feed feed parser package which uses native code as it binds to a C++ library. Lots of changes had to be made although all of them were trivial. These included changing things like:

  • NanNew<Object> to Nan::New<Object>()
  • something->Set(NanNew<String>("name"), NanNew<String>(name)) to
    Nan::Set(extension, Nan::New("name").ToLocalChecked(), Nan::New<String>(name).ToLocalChecked())
  • etc.

The full changeset is available here.

Travis and old GCC

Node version 4 is unofficially supported on Travis CI. It can be used for testing pure JavaScript packages but it has issues with compiling native addons. The issue turns out to be a too old GCC version (not supporting enough C++11). This can be worked around. For the fast-feed package, the fix was contributed by Edward Vielmetti. Now Travis shows all green again with all major Node.js and io.js versions.

Next steps

The merge should agitate people to use more ES6 as Node.js has now much better support for ES6 features. It would be nice if more packages (and the Node.js library) supported promises. Promises are natively available in the version 4 but the fs module is not using them yet. There also seems to be no promisify function built-in. Returning promises from the fs module has been proposed couple of times in the issue tracker but it has not found much support yet.

Built-in NAN/native abstraction?

V8 API has not proved to be very stable between releases and that causes issues for native addons. As one of the solutions, building in NAN has been proposed. However, this is still an open issue.


No comments have been added so far.

Email is not displayed anywhere.
URLs (max 3) starting with http:// or https:// can be used. Use @Name to mention someone.