Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  194] [ 7]  / answers: 1 / hits: 109842  / 9 Years ago, wed, september 2, 2015, 12:00:00

I'm trying to run node.js backend server. I've received error unexpected reserved word on import in Node.js file.



The lines in file core.module.js is:



'use strict';
import lodashMixins from './lodashMixins.js'
... other imports and configurations ...


I launch simple command: node core.module.js



It's not uncommon error, but usually it happens with other libraries. I haven't seen solution for Node.js. How should I fix this? I'm using Windows Server.



Edit: I've find out that it's ES6, but how could I launch it? It looks like backend for the application, but I have no idea what command should I use to launch it without errors.


More From » node.js

 Answers
23

The import keyword is part of the modules feature in ECMAScript 2015, along with export and a few other specifications.



It is currently not implemented natively in NodeJS, even on the lastest version (v0.12.7), nor is it supported in the ES2015 friendlier fork iojs.



You will need to use a transpiler to get that to work.



[edit] it's still unsupported in the latest version (v5.8) despite the existence of an --harmony_modules flag, which does nothing. Your best run is to use babel, as explained here and here


[#65217] Monday, August 31, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
domeniccolti

Total Points: 276
Total Questions: 98
Total Answers: 93

Location: India
Member since Fri, May 13, 2022
2 Years ago
domeniccolti questions
Mon, Oct 18, 21, 00:00, 3 Years ago
Thu, Oct 14, 21, 00:00, 3 Years ago
Thu, Jul 15, 21, 00:00, 3 Years ago
Sat, Oct 24, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;