gruntfile 在终端中给我错误

gruntfile is giving me errors in terminal

学习 grunt.js 并且我在终端中不断收到此错误。

运行 "sass:dist" (sass) 任务 警告:路径必须是字符串。收到未定义使用 --force 继续。

由于警告而中止。

这是代码。任何帮助都会很棒

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    /** Sass task **/
    sass: {
      dev: {
        options: {
          style: 'expanded',
          sourcemap: 'none',
        },
        files: {
          'compiled/style.css': 'sass/style.scss'
        }
      },
      dist: {
        options: {
          style: 'compressed',
          sourcemap: 'none',

        },
        files: {
          'compiled/style-min.css': 'sass/style-min.scss'
        }
      }
    },

    /** Watch task **/
    watch: {
      css: {
        files: '**/*.scss',
        tasks: ['sass']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default', ['watch']);
}

这是我的 json

{
  "name": "millervolpe2016",
  "version": "1.0.0",
  "description": "Our company's new theme",
  "main": "index.php",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/jspraguemillervolpe/miller-volpe.git"
  },
  "keywords": [
    "miller",
    "volpe"
  ],
  "author": "Jason Sprague",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/jspraguemillervolpe/miller-volpe/issues"
  },
  "homepage": "https://github.com/jspraguemillervolpe/miller-volpe#readme",
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-autoprefixer": "^3.0.4",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-watch": "^1.0.0"
  },
  "dependencies": {}
}

你的 sass dist: 和 files: 应该是这样的:

files: {
       'compiled/style-min.css': 'sass/style.scss'
}

您指向的文件是 sass/style.scss 因此您应该对 dist 和 dev 使用相同的文件。

这个文件:'sass/style-min.scss' 在你的项目和你的开发中不存在 sass 你正在使用:'sass/style.scss',我现在在这里做了一个测试 sass:dist如果你改变这个就可以正常工作。

如果这能解决您的问题,请告诉我。

谢谢。