2016-05-08 99 views
0

我使用Angular與gulp。當我做一個「吞噬測試」,我得到了錯誤「ReferenceError:無法找到變量:需要在/bower_components/gulp-ng-config/gulp-ng-config.js:3找不到變量:require

gulp/config。 JS

'use strict'; 

var path = require('path'), 
    gulp = require('gulp'), 
    conf = require('./conf'), 
    gulpNgConfig = require('gulp-ng-config'); 

gulp.task('config', function() { 
    gulp.src(path.join(conf.paths.src, '/app/config.json')) 
    .pipe(gulpNgConfig('EnvConf', { 
     environment: 'local' 
    })) 
    .pipe(gulp.dest(path.join(conf.paths.src, '/app/'))); 
}); 

gulp.task('config:build', function() { 
    gulp.src(path.join(conf.paths.src, '/app/config.json')) 
    .pipe(gulpNgConfig('EnvConf', { 
     environment: 'production' 
    })) 
    .pipe(gulp.dest(path.join(conf.paths.src, '/app/'))); 
}); 

一飲而盡/ server.js

gulp.task('serve', ['config','watch'], function() { 
    browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src]); 
}); 

gulp.task('serve:dist', ['config:build','build'], function() { 
    browserSyncInit(conf.paths.dist); 
}); 

gulp.task('serve:e2e', ['config','inject'], function() { 
    browserSyncInit([conf.paths.tmp + '/serve', conf.paths.src], []); 
}); 

gulp.task('serve:e2e-dist', ['config:build','build'], function() { 
    browserSyncInit(conf.paths.dist, []); 
}); 

我嘗試節點V6.1.0和v5.10.1。

+0

安裝是否安裝[節點](https://nodejs.org/en/)? –

+0

node --version v5.10.1 – Sancho

回答

0

看起來你已經安裝gulp-ng-conig作爲涼亭依賴。

這是一個gulp插件,它是一個節點依賴項

嘗試npm install gulp-ng-config --save