question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing ES2015 module throw syntax error

See original GitHub issue

I’m submitting a bug report

  • Library Version: 0.21.1 (aurelia-cli)
  • Operating System: OSX 10.12.3
  • Node Version: 7.4.0
  • NPM Version: 4.0.5
  • Browser: all
  • Language: TypeScript 2.2.1

Current behavior: I have installed a library that’s coded using ES2015 syntax and when I’m requiring it inside the aurelia_project/aurelia.json esprima give me syntax error.

{ uid: 0,
  name: '<series>',
  branch: true,
  error:
   Error: Parse error using esprima for file: /Users/romainlanz/workspace/app.org/node_modules/myPackage/lib/index.js
   Error: Line 2: Unexpected token
  ....
}

Here’s the content of the file (TypeScript compiled to ES2015):

'use strict';
export * from './Auth';
export * from './Beach';
export * from './Requests';
export * from './Services';
export * from './Core';
//# sourceMappingURL=index.js.map

What is the expected behavior? I expect Aurelia to require my package without throwing an error.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:20 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
jwxcommented, Jun 14, 2017

@RomainLanz Is this issue resolved in version 0.30 of the CLI?

0reactions
3cpcommented, Feb 4, 2019

Yes, new tracer supports esm module format.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript ES2015 import throws Uncaught SyntaxError
I can reference css files from my main.css by adding @import "@material/textfield/dist/mdc.textfield.css"; to the start of my stylesheet. This ...
Read more >
JS Fix For "SyntaxError: Cannot Use Import Statement Outside ...
This is most likely triggered when a file tries to use both import and require module patterns, which isn't possible. You'll need to...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings ... or "function body" as parsing goals), a SyntaxError is thrown.
Read more >
cannot use import statement outside a module - You.com
json will tell Node you are using ES2015 modules, which should get rid of the error, but then you will need to tell...
Read more >
Learn ES2015 - Babel.js
ES2015 classes are syntactic sugar over the prototype-based OO pattern. ... app.js import * as math from "lib/math"; console.log("2π = " + math.sum(math.pi, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found