SyntaxError: Unexpected end of input error using Gulp and main-bower-files package
SyntaxError: Unexpected end of input error using Gulp and main-bower-files package
我一直在尝试将主要的 Bower 文件注入我的构建文件夹时出错 index.html
我正在使用 main-bower-files NPM package。
我的代码如下所示:
//requires
var gulp = require('gulp');
var inject = require('gulp-inject');
var config = require('./gulp-config');
var mainBowerFiles = require('main-bower-files');
gulp.task('default', ['move'], function() {
return gulp
.src(config.buildFolder + config.indexFile)
.pipe(
inject(
gulp.src( mainBowerFiles() ), {base: './bower_components'}
)
)
.pipe(gulp.dest(config.buildFolder));
});
gulp.task('move', function() {
return gulp
.src(config.indexFile)
.pipe(gulp.dest(config.buildFolder));
});
这给了我以下错误
SyntaxError: Unexpected end of input
所以这件事真的让我很烦(我正在偷看 NPM 包代码的幕后,看看是否真的有输入错误的意外结束,但错误是我的错)。
问题出在我的文件结构中,我有一个空的 .bowerrc 文件,它是我通过键入 $ touch .bowerrc
从终端生成的。只需添加
{
"directory": "(your bower components folder here as valid JSON)"
}
并且...错误消失了!希望这能像给我带来的麻烦一样为别人省去麻烦。
我一直在尝试将主要的 Bower 文件注入我的构建文件夹时出错 index.html
我正在使用 main-bower-files NPM package。
我的代码如下所示:
//requires
var gulp = require('gulp');
var inject = require('gulp-inject');
var config = require('./gulp-config');
var mainBowerFiles = require('main-bower-files');
gulp.task('default', ['move'], function() {
return gulp
.src(config.buildFolder + config.indexFile)
.pipe(
inject(
gulp.src( mainBowerFiles() ), {base: './bower_components'}
)
)
.pipe(gulp.dest(config.buildFolder));
});
gulp.task('move', function() {
return gulp
.src(config.indexFile)
.pipe(gulp.dest(config.buildFolder));
});
这给了我以下错误
SyntaxError: Unexpected end of input
所以这件事真的让我很烦(我正在偷看 NPM 包代码的幕后,看看是否真的有输入错误的意外结束,但错误是我的错)。
问题出在我的文件结构中,我有一个空的 .bowerrc 文件,它是我通过键入 $ touch .bowerrc
从终端生成的。只需添加
{
"directory": "(your bower components folder here as valid JSON)"
}
并且...错误消失了!希望这能像给我带来的麻烦一样为别人省去麻烦。