What does “Verifying property ___ exists in config

2019-07-07 06:38发布

I have a simple Gruntfile written in Coffeescript:

"use strict"

module.exports = (grunt) ->

    config =
        src: "app"
        dist: "build"

    grunt.initConfig =
        config: config
        copy:
            dist:
                files: [
                    expand: true
                    cwd: "<%= config.app %>"
                    dest: "<%= config.dist %>"
                    src: [
                        "*.{ico,png}"
                        "{*/}*.html"
                    ]
                ]

    grunt.loadNpmTasks "grunt-contrib-copy"

    grunt.registerTask "build", [
        "copy:dist"
    ]

    grunt.registerTask "default", [
        "build"
    ]

Which throws the following error when run:

Verifying property copy.dist exists in config...ERROR
>> Unable to process task.
Warning: Required config property "copy.dist" missing. Use --force to continue.

What is this referring too? It seems like copy.dist is present, so why is it not being read?

Also, I assume this is a Coffeescript formatting issue because the equivalent Gruntfile written in Javascript doesn't throw this issue:

"use strict";

module.exports = function (grunt) {

    // Configurable paths
    var config = {
        scr: "app",
        dist: "build"
    }

    grunt.initConfig({

        // Project settings
        config: config,

        copy: {
            dist: {
                files: [{
                    expand: true,
                    cwd: "<%= config.app %>",
                    dest: "<%= config.dist %>",
                    src: [
                        "*.{ico,png}",
                        "{*/}*.html"
                    ]
                }]
            }
        }
    });

    // Install plugins
    grunt.loadNpmTasks("grunt-contrib-copy");

    grunt.registerTask("build", [
        "copy:dist"
    ]);

    grunt.registerTask("default", [
        "build"
    ]);

};

1条回答
Rolldiameter
2楼-- · 2019-07-07 06:58

I can not see config.app in your config block, I only can see config.src which contains a string ("app").

So I would try to swap cwd: "<%= config.app %>" to cwd: "<%= config.src %>".

Hope that would help.

查看更多
登录 后发表回答