node.js - Webstorm Unexpected Token export -


i having "unexpected token export" issue in webstorm has not been solved other stackoverflow posts. trying use import/export module functionality package.json , bar.js code below. using node.js 5x, babel 6, , have file watcher setup babel transforms on fly.

the code should speak itself, , appreciate thoughts on how resolve it. again, have tried other stackoverflow suggestions no luck @ point.

//bar.js  'use strict';  export class bar{     constructor(){         this.tempish = 'allo';     } }  //bar-compiled.js  'use strict';  object.defineproperty(exports, "__esmodule", {     value: true });  function _classcallcheck(instance, constructor) { if (!(instance instanceof constructor)) { throw new typeerror("cannot call class function"); } }  var bar = exports.bar = function bar() {     _classcallcheck(this, bar);      this.tempish = 'allo'; };  //# sourcemappingurl=bar-compiled.js.map  //index.js  'use strict';  import {bar} './bar'  console.log('this test.');  //index-compiled.js  'use strict';  var _bar = require('./bar');  console.log('this test.');  //# sourcemappingurl=index-compiled.js.map  //package.json  {   "name": "npt-test",   "version": "1.0.0",   "description": "",   "main": "index-compiled.js",   "scripts": {     "test": "echo \"error: no test specified\" && exit 1"   },   "author": "",   "license": "isc",   "dependencies": {     "babel": "^6.3.26",     "babel-cli": "^6.4.5",     "babel-core": "^6.4.5",     "babel-plugin-transform-decorators-legacy": "^1.3.4",     "babel-preset-es2015": "^6.3.13",     "babel-preset-stage-0": "^6.3.13"   } }  //.babelrc  {     "presets": ["es2015", "stage-0", "stage-1"],     "plugins": ["babel-plugin-transform-decorators-legacy"] }  //error on debug, running against index-compiled.js during debug  c:\program files (x86)\jetbrains\webstorm 11.0.3\bin\runnerw.exe" "c:\program files\nodejs\node.exe" --debug-brk=45287 --nolazy index-compiled.js debugger listening on port 45287 [myprojectdir]\bar.js:3 export class bar{ ^^^^^^  syntaxerror: unexpected token export     @ exports.runinthiscontext (vm.js:53:16)     @ module._compile (module.js:373:25)     @ object.module._extensions..js (module.js:404:10)     @ module.load (module.js:343:32)     @ function.module._load (module.js:300:12)     @ module.require (module.js:353:17)     @ require (internal/module.js:12:17)     @ object.<anonymous> ([myprojectdir]\index-compiled.js:3:12) @ module._compile (module.js:397:26) @ object.module._extensions..js (module.js:404:10) 

process finished exit code 1

what index-compiled.js code like? seems requires original bar.js rather bar-compiled.js. node.js can't natively execute es6 code, errors.

i'd recommend configuring compiler output transpiled code separate directory avoid using 'compiled' postfix. please see following link instructions on setting babel 6 webstorm: http://mcculloughwebservices.com/2015/12/10/webstorm-babel-6-plugin/


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -