【问题标题】:"Arguments to path.join must be strings" in grunt using expand option“path.join 的参数必须是字符串”在 grunt 中使用扩展选项
【发布时间】:2013-06-10 19:04:56
【问题描述】:

thisthis 问题不重复。不过非常相似。

我的目标很简单——编译 coffeescript 文件,所以我有这个 Gruntfile.js

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

        coffee:{
            compile: {
                expand: true,
                flatten: true,
                cwd: 'js/',
                src: ['*.coffee'],
                dest: ['js/prod/'],
                ext: '.js'
            }           
        }
    });

    grunt.loadNpmTasks('grunt-contrib-coffee');
};

运行 `grunt coffee' 后,我收到 警告:path.join 的参数必须是字符串使用 --force 继续。 没有编译任何内容。为什么?

我不认为我需要重新安装某些东西,因为我在两天前安装了 grunt,而不是在完成与此问题相关的任何错误修复之前。而且我知道我可以使用另一种语法,但我需要打开这个 expand 选项。

【问题讨论】:

  • @user1737909 不,这是 Debian Squeeze

标签: coffeescript gruntjs


【解决方案1】:

虽然之前的答案应该已经解决了您的问题,但如果没有,请尝试运行以下命令。

npm cache clean && rm -rf node_modules/grunt && npm install grunt

【讨论】:

    【解决方案2】:

    您的dest 应该是String 而不是Array

    module.exports = function(grunt){
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
    
            coffee:{
                compile: {
                    expand: true,
                    flatten: true,
                    cwd: 'js/',
                    src: ['*.coffee'],
                    dest: 'js/prod/',
                    ext: '.js'
                }           
            }
        });
    
        grunt.loadNpmTasks('grunt-contrib-coffee');
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-22
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      • 2015-06-08
      • 2014-01-23
      相关资源
      最近更新 更多