gulpfile.js中的语法错误

时间:2016-04-03 18:08:55

标签: gulp

我正在用烧瓶做一个简单的应用程序项目并对前端的东西做出反应。对于捆绑和编译即时尝试使用gulp但我遇到了这个错误。

这是我在尝试运行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

这是我的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 个答案:

答案 0 :(得分:2)

您的代码的某些行中包含隐藏的非法字符,从而阻止其运行 https://jsfiddle.net/9mg23vxj/ - 由JSfiddle显示为红点 删除它们,一切都应该没问题。

float readTemperatureRaw()
{
  int val;

  // Command to send to the SHT1x to request Temperature
  int gTempCmd  = 0b00000011;

  sendCommandSHT(gTempCmd);
  ...
  return (val);
}


//Send Command to sensor
void sendCommandSHT(int command)
{
  int ack;

  shiftOut(dataPin, clockPin, MSBFIRST, command);
  ....
}