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.

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

See original GitHub issue

Hello,

I updated babelify to 7.0.2 and now it throws this error:

Browserify Error
/Applications/MAMP/htdocs/folder-name/assets/js/main.js:1
import framework from './framework';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Working with 6.4.0. Do you maybe have any ideas?

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:8
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

211reactions
zertoshcommented, Nov 27, 2015

You upgraded to babelify 7.0, which uses the new babel 6.0, and you’re missing options. Please read the README.

97reactions
baptistebrielcommented, Feb 24, 2016

This is what I needed to do to fix this error:

npm install --save-dev babel-preset-es2015

gulpfile.js:
browserify().transform("babelify", {presets: ["es2015"]});
package.json:
{
  "browserify": {
    "transform": [["babelify", { "presets": ["es2015"] }]]
  }
}

https://github.com/babel/babelify#options

Read more comments on GitHub >

github_iconTop Results From Across the Web

'import' and 'export' may appear only with 'sourceType: module ...
In my case, I was getting this error with browserify and babelify when trying to compile JS files that imported TypeScript files, e.g....
Read more >
'import' and 'export' may appear only with 'sourceType: module ...
ParseError: 'import' and 'export' may appear only with 'sourceType: module' It happens just after the npm initialization and Budo installation. ...
Read more >
Continued problems with issue #103 ('import' and 'export' may ...
I just ran into the same issue and tried all the options above with no success. I really look forward to a solution....
Read more >
Solved: Bundle Error: 'import' and 'export' may appear onl...
The issue here is that @antv/x6 is published as an ES module, and the Blocks CLI currently only supports commonjs node dependencies. This...
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