Nodejs import error with syntax error
I am using react-router
node module for routing in a related application. I am importing the required modules as follows.
var React = require('react');
var Router = require('react-router');
var { Route, RouteHandler, Link } = Router;
// ... remaining code ...
But I am getting syntax error on line no. 3, i.e.var { Route, RouteHandler, Link } = Router;
Mistake:
Uncaught SyntaxError: Unexpected token {
source to share
Doing:
var {x,y} = {x:3,y:5};
Destination of destruction is called and is a new function in JavaScript, which requires a new JavaScript runtime. This feature is not yet supported in NodeJS and not even in version 8 (JavaScript JavaScript JS works). You can assign it in 3 lines manually, or use a tool like Traceur or Babel to compile your ES6 (new EcmaScript spec) to ES5 (that's what node works).
source to share