4
votes

Starting with AWS-Lambda and the Serverless Framework i am confused about node versions:

The AWS help site says that (on 21-March-2016)

AWS Lambda supports the following runtime versions:

Node.js: v0.10.36

So i did install Node.js v0.10.36 on my local machine. Installing the latest (v 0.4.2) serverless framework via

npm install serverless -g

it gives the following warning:

npm WARN engine [email protected]: wanted: {"node":">=4.0"} (current: {"node":"0.10.36","npm":"1.4.28"})

I thought having the same version locally as on AWS might help having a consistent development environment... Am i wrong? What Node.js version should i run locally to get the most out of serverless?

2
You need to install serverless version that supports node v0.10.36Vsevolod Goloviznin
How can i check, that it does?Rentrop
you'd better ask the contributors of this package regarding that, or check the versions yourselfVsevolod Goloviznin
@Floo0, I am running node v5.1.0 on my machine and serverless v0.4.2. The only problematic thing for me was ECMA 2015. I would suggest to install node versions as sls asks "node":">=4.0". I have not heard anyone in the community struggling with this version mismatch. I am not saying it is perfect, people are still waiting for Lambda team to update node version.Alua K
@AluaK Thank you very much. Just updated my node version. So far everything worksRentrop

2 Answers

6
votes

The Serverless Framework requires Node.js v4.0 or higher. Any version of Node.js within the v4.x or v5.x lines should work.

You are correct that AWS Lambda currently only supports Node.js v0.10.36. The decision to build the Serverless Framework on Node.js v4.0 was done in anticipation that AWS Lamabda would eventually support Node.js v4.0 or higher.

When developing code for AWS Lambda, you should continue to only use features compatible with Node.js v0.10.36. If you make any contributions to the framework, you can use Node.js features available in v4.0+.

Another option is to use Babelify to transform your ES2015 code uploading to AWS Lambda. This allows you to develop in ES2015 without having to wait for AWS Lambda to officially support it. This can be done automatically each time you deploy with the Serverless Framework using the Optimizer Plugin.

Update: A new option now exists, the Serverless Babel Runtime. This goes one step beyond what Optimizer does, and uses Babel inside the runtime itself.

Update 2: AWS Lambda now supports Node.js v4.3.

1
votes

If you are starting out with a brand new, fresh project I would highly avoid starting with node 0.10.x. That version is just receiving important security fixes at this point, and only for another five months (until October 2016).

The Node.js has adopted the common Long Term Support (LTS) pattern to keep releases timely and stable. Here is the current LTS plan for node.

I would highly recommend starting out with version 4 or 5, depending on your appetite for change and keeping your project up to date. You will be able to take advantage of numerous new features over the 0.10/0.12 releases as well as better prepare you for ES6.