草庐IT

javascript - 语法错误 : Unexpected end of input error using Gulp and main-bower-files package

coder 2024-07-29 原文

在尝试将主要的 Bower 文件注入(inject)我的构建文件夹 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)"
}

然后...错误消失了!希望这能像给我带来的麻烦一样为其他人省去麻烦。

关于javascript - 语法错误 : Unexpected end of input error using Gulp and main-bower-files package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29979990/

有关javascript - 语法错误 : Unexpected end of input error using Gulp and main-bower-files package的更多相关文章

随机推荐