由于警告““” path“参数必须为字符串类型,如何解决已中止的”正在运行“ sass:dist”(sass)任务”。

时间:2019-01-24 10:48:46

标签: sass gruntjs

我尝试建立一个Grunt / SASS / Bootstrap环境,以使用SASS进行设计。当我想用grunt运行我的“编译”任务时,出现此错误:

aerithe77@aerithe77:~/programmation/test$ grunt compile
Running "sass:dist" (sass) task
Warning: The "path" argument must be of type string. Received type 
undefined Use --force to continue.

Aborted due to warnings.
aerithe77@aerithe77:~/programmation/test$ 
/home/aerithe77/.rvm/rubies/ruby- 
2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb:289:in 
`find_spec_for_exe': can't find gem sass (>= 0.a) with executable 
sass (Gem::GemNotFoundException)
from /home/aerithe77/.rvm/rubies/ruby- 
2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb:308:in 
`activate_bin_path'
from /home/aerithe77/.rvm/gems/ruby-2.3.1/bin/sass:23:in 
`<main>'
from /home/aerithe77/.rvm/gems/ruby- 
2.3.1/bin/ruby_executable_hooks:24:in `eval'
from /home/aerithe77/.rvm/gems/ruby- 
2.3.1/bin/ruby_executable_hooks:24:in `<main>'

我的gruntfile:

module.exports = function(grunt) {

grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  sass: {
    dist: {
      options: {
        style: 'expanded'
      },
      files: {
        'public/css/bootstrap.css': 'node_modules/bootstrap/scss/bootstrap.scss',
        'public/css/custom.css': 'sass/custom.scss'
      }
    }
  },
      concat: {
        options: {
          separator: ';'
        },
        dist: {
          src: ['src/**/*.js'],
          dest: 'dist/<%= pkg.name %>.js'
        }
      },
      uglify: {
        options: {
          banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        dist: {
          files: {
            'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
          }
        }
      },
      qunit: {
        files: ['test/**/*.html']
      },
      jshint: {
        files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
        options: {
          // options here to override JSHint defaults
          globals: {
            jQuery: true,
            console: true,
            module: true,
            document: true
          }
        }
      },
      watch: {
      options: { livereload: true },
        sass: {
          files: ['public/css/custom.css', 'public/'],
          tasks: ['newer:sass:dist'],
        }
    },
      connect
      : {
    server: {
      options: {
        port: 9005,
        base: 'public',
        hostname: '*',
        livereload:true
      }
    }
  }
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');

grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('compile', ['sass','concat', 'uglify']);
grunt.registerTask('default', ['compile','connect','watch']);
}; 

我必须使用该package.json使用npm install进行安装:

{
  "name": "test",
  "version": "0.1.0",
  "description": "test",
  "main": "gruntfile.js",
  "scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
 },
 "author": "Aerithe77",
 "license": "ISC",
 "devDependencies": {
 "connect-livereload": "^0.6.1",
 "grunt": "^1.0.3",
 "grunt-contrib-compass": "^1.1.1",
 "grunt-contrib-concat": "^1.0.1",
 "grunt-contrib-connect": "^2.0.0",
 "grunt-contrib-cssmin": "^3.0.0",
 "grunt-contrib-imagemin": "^3.1.0",
 "grunt-contrib-jshint": "^2.0.0",
 "grunt-contrib-nodeunit": "^2.0.0",
 "grunt-contrib-sass": "^1.0.0",
 "grunt-contrib-uglify": "^4.0.0",
 "grunt-contrib-watch": "^1.1.0"
 },
 "dependencies": {
 "bootstrap": "^4.1.3",
 "jquery": "^3.3.1",
 "popper.js": "^1.12.5"
   }
 }

这是我的第一篇文章,我希望我不要发表嘘嘘的文章。 感谢您的帮助。 (对不起我的英语)

0 个答案:

没有答案