"SyntaxError: 'import' and 'export' may appear only with 'sourceType: module'"
See original GitHub issueNot sure what’s going on, but this message just started showing up…
“SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’”
Here’s the relevant bit from my gulp file:
'use strict';
var gulp = require('gulp'),
notify = require("gulp-notify"),
babelify = require('babelify'),
browserify = require('browserify'),
browserSync = require('browser-sync'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer');
var vendors = [
'jquery',
'moment',
'd3',
'queue-async',
'react',
'react-dom',
'react-bootstrap',
'react-infinite',
'lodash',
'rc-switch',
'rc-slider',
'he',
'react-debounce-input',
'react-swipe-views',
'react-modal',
];
gulp.task('app', function () {
var stream = browserify({
entries: ['./app/app.jsx'],
transform: [babelify],
debug: false,
extensions: ['.jsx'],
fullPaths: false
});
vendors.forEach(function(vendor) {
stream.external(vendor);
});
return stream.bundle()
.pipe(source('build.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('build/js'))
.pipe(notify("Successfully built build.min.js file!"));
});
I’m not sure what happened, but things were fine just a few days ago. Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (9 by maintainers)
Top 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 >Babelify error: 'import' and 'export' may appear only ... - GitHub
It is failing with the error: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (4819:0) while parsing ...
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 >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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You upgraded to babelify 7.0, which uses the new babel 6.0, and you’re missing options. Please checkout the README.
I’m sorry you feel that way. I offered to personally debug your issue if you provided me with some code. I didn’t meant to offend. Please remember that we’re all volunteers here and just trying to make cool things.