Gulp停止了工作并且说道路没有定义'

时间:2017-07-10 08:52:15

标签: node.js gulp bower

我对gulp相当新,但是它工作得很好。 几天后再回来,它显示错误。 我现在也必须在我之前不需要sudo npm install,并且我做的一些步骤导致我的主js文件需要密码才能保存。这可能是错误的根源吗?

以下是错误消息:

ReferenceError: paths is not defined
at Object. (/Applications/AMPPS/www/site/wp-content/themes/myproject/gulpfile.js:34:75)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff. (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:198:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)

Gulpfile

var gulp = require('gulp')
var bower = require('gulp-bower')
var mainBowerFiles = require('main-bower-files')
// var path = require('path')

var sass = require('gulp-sass')
var autoprefixer = require('gulp-autoprefixer')
var cssmin = require('gulp-cssmin')
// var minifycss = require('gulp-uglifycss') // Minifies CSS files

var sass = require('gulp-sass'); // Gulp pluign for Sass compilation
var autoprefixer = require('gulp-autoprefixer'); // Autoprefixing magic

// JS related plugins.
var concat = require('gulp-concat'); // Concatenates JS files
var uglify = require('gulp-uglify'); // Minifies JS files

// Utility related plugins.
var rename = require('gulp-rename'); // Renames files E.g. style.css -> style.min.css
var sourcemaps = require('gulp-sourcemaps'); // Maps code in a compressed file (E.g. style.css) back to it’s original position in a source file (E.g. structure.scss, which was later combined with other css files to generate style.css)
var notify = require('gulp-notify'); // Sends message notification to you
var pump = require('pump');
var plumber = require('gulp-plumber');

// Tasks

gulp.task('bower', function() {
return gulp.src(mainBowerFiles('**/*.min.js'), { base: 'bower_components' })
.pipe(gulp.dest('library/js/libs'))
});

var buildVendors = gulp.src(mainBowerFiles('**/*.min.js')).pipe(gulp.dest(paths.buildBower));
return gulp.src(paths.index)
.pipe(inject(buildBowerFiles,{
relative: true,
name: 'bowerInject'
}));

var config = {
srcCss : 'library/scss/**/*.scss',
buildCss: 'library/css',
buildJs: 'library/js',
}

gulp.task('build-css', function(cb) {
gulp.src(config.srcCss)

  // output non-minified CSS file
  .pipe(sass({
     outputStyle : 'expanded'
  }).on('error', sass.logError))
  .pipe(autoprefixer())
  .pipe(gulp.dest(config.buildCss))

  // output the minified version
  .pipe(cssmin())
  .pipe(rename({suffix: '.min'}))
  .pipe(gulp.dest('library/css'));

cb()
})

gulp.task('build-js', function () {
gulp.src('library/js/scripts.js')
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('library/js'))
})

gulp.task('watch', function(cb) {
gulp.watch(config.srcCss, ['build-css'])
gulp.watch(config.buildJs, ['build-js']);
})

gulp.task('default', ['build-css', 'build-js', 'watch'])

你使用的是什么版本的gulp?

[22:10:02] CLI版本3.9.1 [22:10:02]本地版本3.9.1

您使用的是哪种版本的npm和节点? npm 2.12.0 节点v0.12.0

0 个答案:

没有答案