为什么 Grunt 文件中止并显示消息 Arguments to path.join must be strings Use --force to continue

Why does Grunt file aborts with message Arguments to path.join must be strings Use --force to continue

我正在为手头的一个小项目创建以下 grunt 文件。但是,它中止并显示以下消息

Running "sass:dev" (sass) task
Warning: Arguments to path.join must be strings Use --force to continue.

我哪里做错了?有人可以给我解释一下吗?

/*!
 * XXX
 * @author XXXXXX
 */

'use strict';

/**
 * Grunt Module
 */

module.exports = function(grunt) {
  // Grunt goodness goes here
    /**
     * Configuration
     */
    grunt.initConfig({
        /**
         * Get package meta data
         */
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Set project object
         */
        project: {
          app: 'app',
          assets: '<%= project.app %>/assets',
          src: '<%= project.assets %>/src',
          css: [
            '<%= project.src %>/styles/*.scss'
          ],
          js: [
            '<%= project.src %>/scripts/*.js'
          ],
          dist: '<%= project.assets %>/dist',
          distcss: [
            '<%= project.dist %>/styles/*.scss'
          ],
          distjs: [
            '<%= project.dist %>/scripts/*.js'
          ],
        },   

        /**
         * Project banner
         */
        tag: {
          banner: '/*!\n' +
                  ' * <%= pkg.name %>\n' +
                  ' * <%= pkg.title %>\n' +
                  ' * <%= pkg.url %>\n' +
                  ' * @author <%= pkg.author %>\n' +
                  ' * @version <%= pkg.version %>\n' +
                  ' * Copyright <%= pkg.copyright %>. <%= pkg.license %> licensed.\n' +
                  ' */\n'
        },

        /**
         * Sass
         */
        sass: {
          dev: {
            options: {
              style: 'expanded',
              banner: '<%= tag.banner %>',
              compass: true
            },
            files: {
              '<%= project.css %>': '<%= project.distcss %>'
            }
          },
          dist: {
            options: {
              style: 'compressed',
              compass: true
            },
            files: {
              '<%= project.css %>': '<%= project.distcss %>'
            }
          }
        },
        /**
         * Watch
         */
        watch: {
          sass: {
            files: '<%= project.src %>/styles/{,*/}*.{scss,sass}',
            tasks: 'sass:dev'
          }
        },
        // Uglify
        uglify: {
            options: {
              banner: '/*! <%= pkg.name %>  Version: <%= pkg.version %> Created on: <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            build: {
              src: 'src/scripts/*.js',
              dest: 'build/<%= pkg.name %>.min.js'
            }
        }
    });
    /**
     * Load Grunt plugins
     */
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    /**
     * Default task
     * Run `grunt` on the command line
     */
    grunt.registerTask('default', [
      'sass:dev',
      'watch'
    ]);

};

当使用 something.css : something.scss 语法为 sass 任务指定 files 时,您不能使用星号来包含多个文件。您要么必须单独指定每个文件,如下所示:

files: {
  'one.css': 'one.scss',
  'two.css': 'two.scss',
  'three.css': 'three.scss',
}

或者,更好的是,使用 expand 属性 对目录中的所有文件执行此操作,如下所示:

files: [{
  expand: true,
  cwd: '<%= project.src %>/styles',
  src: ['*.scss'],
  dest: '<%= project.src %>/styles',
  ext: '.css'
}]

grunt-contrib-sass readme.

中有更多相关信息