我package.json
是:爲什麼我的ES6節點應用程序不能在彈性beanstalk中運行?
{
"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"
}
}
而且我.elasticbeantalk/config.yml
是
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
但是當我部署和執行,我得到了502
錯誤。於是我查了一些日誌,它似乎是ES6不支持:
============= 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)
我在做什麼錯?
是在您的EBS實例上運行什麼版本的節點? – Pytth
我如何知道?它不應該尊重'package.json'中我的'engines'嗎? – Shamoon