Gruntjs 哪个路径需要是字符串?

Gruntjs 哪个路径需要是字符串?,gruntjs,grunt-contrib-watch,Gruntjs,Grunt Contrib Watch,第一次运行Grunt和Sass时,我在终端中修改scss文件时遇到此错误: danales-MacBook-Pro:sass-test danale$ grunt Running "watch" task Waiting... >> File "SCSS/_main.scss" changed. Running "sass:dev" (sass) task Warning: Path must be a string. Received undefined Use --force t

第一次运行Grunt和Sass时,我在终端中修改scss文件时遇到此错误:

danales-MacBook-Pro:sass-test danale$ grunt
Running "watch" task
Waiting...
>> File "SCSS/_main.scss" changed.
Running "sass:dev" (sass) task
Warning: Path must be a string. Received undefined Use --force to continue.

Aborted due to warnings.
Completed in 0.587s at Thu Apr 20 2017 12:47:54 GMT-0400 (EDT) - Waiting...
>> File "SCSS/_mixins.scss" changed.
Running "sass:dev" (sass) task
Warning: Path must be a string. Received undefined Use --force to continue.

Aborted due to warnings.
Completed in 0.545s at Thu Apr 20 2017 12:49:12 GMT-0400 (EDT) - Waiting...
据我所知,错误是Grunfile中的路径必须是字符串:

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    /**
    * SASS
    */
    sass: {
      dev: {
      options: {
        style: 'expanded',
          sourcemap: 'none',
        },
        files: {
          'style.css': 'scss/style.css'
        }
      }
    },

    /**
    * watch
    */
    watch: {
        css: {
          files: '**/*.scss',
          tasks: ['sass']
        }
    },
  });
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default',['watch']);
}

但我不清楚哪个路径需要是字符串…

它的意思是,您指向的sass文件不在那里。从
watch
输出中,我可以看到该目录实际上被称为
SCSS/
(而不是
SCSS/
)。此外,您还没有指明要预处理的scss文件。尝试更改
sass
任务配置,以指示正确的目录和主scss文件:

files: {
    'style.css': 'SCSS/_main.scss'  // update this match your PRIMARY scss file
}

jakerella,我更改了它以反映您的答案中的内容,但我仍然收到以下错误:>>文件“SCSS/_main.SCSS”已更改。正在运行“sass:dev”(sass)任务警告:路径必须是字符串。接收到未定义的使用--强制继续。当它这么说时,几乎总是因为它要查找的文件实际上并不存在。仔细检查这些路径。