I am a newbie in JS and I have some troubles running the test server (like: node app.js ..or iojs app.js) with the new ECMA6 syntax (using import and export)... here is the sample code I am using trying to achive that and the error the server is returning :
<script>
System.config({
baseURL:"/",
transpiler: "babel",
babelOptions: {
"optional": [
"runtime"
]
},
paths: {
"npm:*": "node_modules/*",
"bower:*": "bower_components/*"
},
map: {
"babel": "npm:babel-core/browser.js",
"sammy": "bower:sammy/lib/sammy.js",
"jquery":"bower:jquery/dist/jquery.js",
"handlebars": "bower:handlebars/handlebars.js"
}
});
</script>
<script type="text/javascript">
System.import('app.js')
.then(function(module) {
module.init('#content');
});
</script>
and in app.js the following simple code :
import $ from 'jquery';
import sammy from 'sammy';
import homeController from './controllers/homeController.js';
export function init (element) {
var sammyApp = Sammy(element, function() {
this.get('#/', homeController.load);
});
sammyApp.run('#/');
}
then o recive the following error screen when trying to execute the test server:
D:\TELERIK\JavaScript-Apps\exam-prepar-evlogi>iojs app.js
D:\TELERIK\JavaScript-Apps\exam-prepar-evlogi\app.js:1
(function (exports, require, module, __filename, __dirname) { import $ from 'j
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
at startup (node.js:117:18)
at node.js:948:3
Any advice on where my fault is would be great.. Thank you all in advance