I have file with a ES6 class with default export:
accessmanager.js
export default class AccessManagerClient {
constructor(){
...
}
}
And I want to import it like this:
anotherFile.js
import AccessManagerClient from '../someFolder/accessmanager';
When I run my spec I get an error:
import AccessManagerClient from '../someFolder/accessmanager';
^^^^^^
SyntaxError: Unexpected token import
I have such npm and node versions:
$ npm -v
5.3.0
$ node -v
v8.0.0
You can't without Babel or some other packager/bundler/transpiler, because Node doesn't have native support for import
/export
yet. Either use Node's own modules, or a packager/bundler/transpiler.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments