1

I have cloned a repo with a working gulpfile.js, and now when running gulf on the cloned repo, I received the error

Object #<Object> has no method 'if'

The offending task code: gulp.task('html', ['styles'], function () {

return gulp.src('app/*.html')
  .pipe($.useref.assets({searchPath: '{.tmp,app}'}))
  .pipe($.if('*.css', $.csso()))
  .pipe($.useref.restore())
  .pipe($.useref())
  .pipe(gulp.dest('dist'));
});

I have installed gulp-if and gulp-csso. $ is

var $ = require('gulp-load-plugins')();

Still learning gulp. Not sure where to go from here.


Permission Denied with Grunt Compass

I'm trying to run a Grunt Compass task and it keeps failing with:

Errno::EACCES on line ["250"] of /opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb: Permission denied @ dir_s_mkdir - /stylesheets

My task is:

compass: {
  dev: {
    options: {
        require: ['susy', 'breakpoint'],
        sassDir: '<%= paths.srcAssets %>/stylesheets',
        cssDir: '<%= paths.build %>/stylesheets',
        generatedImagesDir: '<%= paths.build %>/images',
        imagesDir: '<%= paths.srcAssets %>/images',
        javascriptsDir: '<%= paths.srcAssets %>/javascripts',
        fontsDir: '<%= paths.srcAssets %>/fonts',
        // importPath: ['<%= paths.vendor %>/components'],
        httpImagesPath: '/assets/images',
        httpGeneratedImagesPath: '/assets/images',
        httpFontsPath: '/assets/fonts',
        sourcemap: true,
        relativeAssets: false,
        noLineComments: true,
        outputStyle: 'compressed',
        raw: 'preferred_syntax = :sass\n',
        environment: 'development',
        bundleExec: true,
        app: 'stand_alone',
        debugInfo: true,
        quiet: false,
        trace: true
    }
  }
},

I'm assuming it's failing as it doesn't have the correct permissions to create the 'stylesheets' directory.

This confuses me in two ways:

  1. I have another grunt task that successfully creates an 'images' directory in the same location that Compass is trying to place the 'stylesheets' one.

  2. I am running this in a Vagrant virtual machine so unsure what the permissions on the parent folder should be.

Any ideas on how to solve it?

Neil

4

1 回答 1

2

package.json中, gulp -if未在 devDependencies 下列出。

  "devDependencies": {
      .
      .
      .
      "gulp-if": "^1.2.5",

包括它消除了错误。

每当安装开发依赖项时,我应该加上 --save-dev 以便包自动放在 package.json 中,然后任何克隆都会通过发出 npm install 命令自动获取 package.json 中的所有包。

npm install <package> --save-dev
于 2014-10-18T19:44:48.327 回答