0

My package.json is:

{
  "name": "api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "babel-node --presets es2015 server.js"
  },
  "engines": {
    "node": "~6.2.2"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel": "^6.23.0",
    "babel-cli": "^6.23.0",
    "babel-preset-es2015": "^6.22.0",
    "body-parser": "^1.16.1",
    "express": "^4.14.1",
    "faker": "^3.1.0",
    "lodash": "^4.17.4"
  }
}

And my .elasticbeantalk/config.yml is

branch-defaults:
  master:
    environment: mysite-api-dev
    group_suffix: null
global:
  application_name: mysite-api
  branch: null
  default_ec2_keyname: mysite-aws
  default_platform: Node.js
  default_region: us-east-1
  profile: eb-cli-mysite
  repository: null
  sc: git

But when I deploy and execute, I get a 502 error. So then I checked some logs and it seems to be that ES6 isn't supported:

============= i-0c6e00622a7b74a8f ==============
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
/var/app/current/server.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash'
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

What am I doing wrong?

Shamoon
  • 41,293
  • 91
  • 306
  • 570

1 Answers1

0

Seems like that you are using eb CLI tool!

Just use eb status in your workspace, and see the platform field to check the current running version of Node.

Documentation of eb CLI: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-status.html

Yueyang Mi
  • 59
  • 3
  • `Platform: 64bit Amazon Linux 2016.09 v3.3.1 running Node.js` – Shamoon Feb 23 '17 at 00:14
  • I'm actually not that familiar with Node, but it seems like that ES6 is not supported by Node yet: https://github.com/nodejs/help/issues/53 – Yueyang Mi Feb 23 '17 at 00:47
  • Similar question about import in NodeJS: http://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import – Yueyang Mi Feb 23 '17 at 00:50