簡體   English   中英

SyntaxError:使用Gulp和main-bower-files包意外結束輸入錯誤

[英]SyntaxError: Unexpected end of input error using Gulp and main-bower-files package

我一直在嘗試將主要的bower文件注入我的構建文件夾index.html時出錯

我正在使用main-bower-files NPM

我的代碼看起來像這樣:

//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)"
}

並且......錯誤消失了! 希望這能給別人帶來盡可能多的麻煩。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM