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.

Another "'import' and 'export' may appear only with 'sourceType: module'" related issue

See original GitHub issue

Hi,

I’m trying to transform a simple ES2015 application using babelify and I’m getting the following error:

export class RebelRouter extends HTMLElement { ^ ParseError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’

I am using the following CLI command:

browserify -e src/app.js -o dist/bundle.js -t [ babelify --presets [ es2015 ] --plugins [ transform-class-properties ]]

I am using the latest version of babel, browserify and babelify.

Transformation with babel alone works perfectly fine.

I’ve also looked at the other similar issues for this project but none of the solutions appear to work for me.

Any help would be greatly appreciated,

Thank you.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
zertoshcommented, Mar 6, 2016

I don’t see anything immediately obvious except the spacing in the brackets - unless that’s bad copy/paste, it would explain why babel isn’t getting your options, and thus not transpiling.

 -t [ babelify --presets [ es2015 ] --plugins [ transform-class-properties ] ]
                                                that space is significant   ^
0reactions
loganfsmythcommented, Sep 3, 2018

I’m triaging old issues on babelify. Since this has been inactive for ages, I’m going to close it. Feel free to re-open if there’s still something to discuss, but I’m assuming at this point it’s been too long to address in a useful way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'import' and 'export' may appear only with 'sourceType: module ...
It seems to be a problem with using a newer version of Babel with babelify. – Mike Cluck. Oct 13, 2016 at 19:15....
Read more >
Continued problems with issue #103 ('import' and 'export' may ...
But the Browserify command is back to failing with the original import/export error. --With @babel/preset-env installed, I tried three different ...
Read more >
SyntaxError: 'import' and 'export' may appear only ... - YouTube
JavaScript : SyntaxError: ' import' and 'export ' may appear only with 'sourceType : module ' - Gulp [ Gift : Animated Search...
Read more >
SyntaxError: 'import' and 'export' may appear only ... - YouTube
react-native: SyntaxError: ' import' and 'export ' may appear only with 'sourceType : module ' (1:0)Thanks for taking the time to learn more....
Read more >
'import' and 'export' may appear only with 'sourceType: module ...
Coding example for the question SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' - Gulp-babel.js.
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