2017-02-21 2 views
0

Mein package.json ist:Warum läuft meine ES6-Knoten-App nicht in elastischem Bohnenranke?

{ 
    "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" 
    } 
} 

Und mein .elasticbeantalk/config.yml ist

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 

Aber wenn ich implementieren und auszuführen, erhalte ich eine 502 Fehler. Also dann habe ich ein paar Protokolle überprüft und es scheint, dass ES6 nicht unterstützt wird:

============= 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) 

Was mache ich falsch?

+0

Welche Version von Knoten auf Ihrer EBS-Instanz läuft? – Pytth

+0

Wie kann ich herausfinden? Sollte es nicht meine 'Engines' in' package.json' respektieren? – Shamoon

Antwort

0

Scheint so, dass Sie eb CLI-Tool verwenden!

Verwenden Sie einfach eb status in Ihrem Arbeitsbereich, und sehen Sie das Plattformfeld, um die aktuell laufende Version von Node zu überprüfen.

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

+0

'Plattform: 64bit Amazon Linux 2016.09 v3.3.1 läuft Node.js' – Shamoon

+0

Ich bin eigentlich nicht so vertraut mit Node, aber es scheint, dass ES6 noch nicht von Node unterstützt wird: https://github.com/nodejs/ help/issues/53 –

+0

Ähnliche Fragen zum Import in NodeJS: http://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import –