Community

Hints for Node.js developers using io.js on Bluemix

Share this post:

If you’re interested in Node.js, but haven’t been following all the latest excitement around io.js and ECMAScript 6 (ES6), here’s the executive summary:

If you’re a current user of node.js, there’s a new kid in town named io.js. It’s a fork of node.js which is shipping with a newer version of the V8 JavaScript engine, and features available in ECMAScript 6, without having to have a special pre-release version of node.js installed, or using special node command-line flags.

Version 1.0.0 of io.js was announced and made available last night and version 1.0.1 was released about an hour later. Later I read this twitter message from Hunter Loftis:

Hunter works on the Heroku Node.js buildpack, which is the basis of the Cloud Foundry Node.js buildpack. So, it’s a good bet the Heroku buildpack will work on Bluemix too.

I gave it a try, and it just worked. Here’s the application I pushed:

https://github.com/pmuellr/bluemix-hello-iojs

It’s my usual Bluemix Hello World Node.js app, but I’ve made a few changes:

  • changed manifest.yml to add the buildpack property pointing to the Heroku buildpack

  • changed package.json to add a new engines property with a iojs property; this is how the buildpack determines it should use io.js instead of node.js

  • changed server.js to use some new ES6 functionality:

    • using let instead of var; note you need to be running in “strict mode” to enable this—enabling strict mode is done by including the string "use strict" at the top of your file
    • using template strings instead of string concatenation.

That last feature is fun, and something I use a lot when I’m writing CoffeeScript. It’s often referred to in other programming languages as “string interpolation”. That is, instead of writing something like this:

log("request " + request.method + " "+ request.url)

you can write

log(`request ${request.method} ${request.url}`)

Check the ES6 on io.js page for more information about enabling other ES6 capabilities in your Node.js applications.

More stories
May 7, 2019

We’ve Moved! The IBM Cloud Blog Has a New URL

In an effort better integrate the IBM Cloud Blog with the IBM Cloud web experience, we have migrated the blog to a new URL: www.ibm.com/cloud/blog.

Continue reading

May 1, 2019

Two Tutorials: Plan, Create, and Update Deployment Environments with Terraform

Multiple environments are pretty common in a project when building a solution. They support the different phases of the development cycle and the slight differences between the environments, like capacity, networking, credentials, and log verbosity. These two tutorials will show you how to manage the environments with Terraform.

Continue reading

April 29, 2019

Transforming Customer Experiences with AI Services (Part 1)

This is an experience from a recent customer engagement on transcribing customer conversations using IBM Watson AI services.

Continue reading