2

Im doing a simple app project with flask and react for the front end stuff. For the bundling and compile im trying to use gulp but i got stuck with this error.

This the error im getting when trying to run gulp:

gulpfile.js:9
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
    at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:193:16)
    at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)
    at Liftoff.<anonymous> (/usr/local/lib/node_modules/gul7

This is my gulpfile.js:

var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var rename = require('gulp-rename');
var es = require('event-stream');
var uglify = require('gulp-uglify');
var buffer = require('vinyl-buffer');
​
gulp.task('transform', function () {
​
    var files = [
        'index.jsx'
    ];
​
    var tasks = files.map(function(entry){
        return browserify({entries: './static/jsx/' + entry})
        .transform('babelify', {presets: ['es2015', 'react']})
        .bundle()
        .on('error', function(err){
            console.log(err.stack);
            this.emit('end');
        })
        .pipe(source(entry))
        .pipe(buffer())
        .pipe(uglify())
        .pipe(rename({
            extname: '.js'
        }))
        .pipe(gulp.dest('./app/static/js'));
    });
​
    return es.merge.apply(null,tasks);

});
​
​
gulp.task('watch', ['transform'], function () {
    gulp.watch('./app/static/jsx/**/*.jsx', ['transform']);
});
​
​
gulp.task('default', ['watch']);

1 Answer 1

2

You have invisible illegal characters in some lines of your code, which prevent it from running.
https://jsfiddle.net/9mg23vxj/ - shown as a red dots by JSfiddle.
Remove them and everything should be ok.

var buffer = require('vinyl-buffer');
​ <--- Here is the symbol.
gulp.task('transform', function () {
​
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.