最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SyntaxError: Unexpected end of input error using Gulp and main-bower-files package - Stack Overflow

programmeradmin3浏览0评论

I keep getting an error trying to inject the main bower files into my build folder index.html

I am using the main-bower-files NPM package.

My code looks like this:

//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_ponents'}
    )
  )
.pipe(gulp.dest(config.buildFolder));
});

gulp.task('move', function() {
  return gulp
    .src(config.indexFile)
    .pipe(gulp.dest(config.buildFolder));
});

which gives me the following error

SyntaxError: Unexpected end of input 

I keep getting an error trying to inject the main bower files into my build folder index.html

I am using the main-bower-files NPM package.

My code looks like this:

//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_ponents'}
    )
  )
.pipe(gulp.dest(config.buildFolder));
});

gulp.task('move', function() {
  return gulp
    .src(config.indexFile)
    .pipe(gulp.dest(config.buildFolder));
});

which gives me the following error

SyntaxError: Unexpected end of input 
Share Improve this question asked May 1, 2015 at 0:32 SethSeth 1972 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

So this one really bugged me (I was peeking under the hood at the NPM package code to see if there really was an unexpected end of input error, but the error was my fault).

The problem is in my file structure, I had an empty .bowerrc file that I generated from the terminal by typing $ touch .bowerrc. Just add

{
    "directory": "(your bower ponents folder here as valid JSON)"
}

and... the error is gone! hope this saves someone else as much trouble as it caused me.

发布评论

评论列表(0)

  1. 暂无评论