2016-04-03 94 views
2

我正在做一個簡單的應用程序項目與瓶和反應的前端東西。對於捆綁和編譯即時嘗試使用吞嚥,但我卡住了這個錯誤。gulpfile.js中的語法錯誤

這個錯誤我嘗試運行時,一飲而盡獲得:

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 

這是我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

你在你的代碼的一些線,防止隱形非法字符它從運行。
https://jsfiddle.net/9mg23vxj/ - 由JSfiddle顯示爲紅色圓點。
刪除它們,一切都應該沒問題。

var buffer = require('vinyl-buffer'); 
​ <--- Here is the symbol. 
gulp.task('transform', function() { 
​