javascript - Node Keystonejs unexpected token export/import -


i'm running keystonejs node webapp , i'm trying include class created reactnative project, i'm getting 'export' unexpected token error , can't find how fix :\, updated node 6.2.0, run node keystone i've tried node --harmony keystone parameter still fails, i've tried installing babel-core babel-cli babel-preset-es2015 , nothing, still can create function (arg) => { /*body*/} form, although don't know in version of ecmascript introduced xd. class declared that: export default class api { ... } api class name, , intend use

import api "api"; api.mymethod().then((res)=>{/*etc*/});

actually unexpected token 'import' before can export, changed 'require' instead, , export error (sorry i'm trying xd) i'm working on mac, built keystone project yo keystone , i've set mongod fine, thing works until try add class, help? plz :\

i used async , await keywords in class methods , think may cause trouble xd, specially because saw 'async' package on package.json file :(, appreciated, thank :3

the error occurs because nodejs has not implemented modules in version 6.20. can obtain list of features being worked on running command:

node --v8-options | grep "in progress" 

you should see line:

--harmony_modules (enable "harmony modules" (in progress)) 

to utilize modules (import, export), you'll need use babel compile javascript files in es2015 es5. can create simple script in package.json:

"compile": "./node_modules/.bin/babel -d dist/ src/" 

the script assumes have babel installed.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo