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

标签 javascript node.js npm gulp bower

在尝试将主要的 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 - 我得到 [1,15],而不是 [1,0,15]。 JavaScript 过滤器

javascript - 简化 Node V8 childprocess.exec

cordova - Ionic cordova 资源 --splash 和 --icon 错误

php - 路由/服务文件(laravel/node js)与简单的 html 'a href' 以便从一个页面导航到另一个页面

node.js - socket.io 与私有(private)房间聊天

javascript - 如何将 RFC822 消息体 body 存储为 String?

node.js - npm-install 不安装子依赖项

php - 使用 php/mysql 在 googlemaps 上动态绘制折线

javascript - 正则表达式 - 检查 url 没有扩展名

javascript - 在 Chrome 扩展中使用 qTip 显示注释