Reputation: 241
I'm working on using Lambda serverless with Node.js. I've created a project in AWS from:
Codestar > Create a new project > Select from Template : Choose Node.js (Web Application + AWS Lamda)
When I open the project in AWS Cloud9, it uses node.js 8.10 for most things, but when it goes to build, it switches to 6.14 and the syntax breaks the build. It is also frustrating because the inline editor on Lambda Management Console has a nice dropdown to specify the version, however I cannot use the inline editor after my project gets too big.
For example, in AWS Cloud9, I click the Run button (at top, after Support | Preview) to test my project, type in a payload, and this syntax is accepted and the test runs:
const responsePost = async (status, eventBody) => {
When I save, git commit, git push, and CodeStar dashboard shows it has finished building, the build fails. In the logs from CodeBuild, it has an error entry:
/codebuild/output/src339298213/src/index.js:19
const responsePost = async (status, eventBody) => {
^
SyntaxError: Unexpected token (
The error goes away by removing the 'async' and '=>'.
In the Cloud9 terminal, when I check the node version it says 6.14.4.
How do I get this process to use Node.js 8.10?
Things I have tried:
template.yml -- set Runtime to nodejs8.10
terminal: nvm to upgrade node.js
Upvotes: 2
Views: 301
Reputation: 5296
Ran into the same issue. You can change it in the build project via the console:
Upvotes: 2