What does "Verify property ___ exist in config" in Grunt mean?

I have a simple Grunt file 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 causes the following error on startup:

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

What does it mean? Copy.dist seems to be present, so why is it not readable?

Also, I assume this is a Coffeescript formatting issue, because the equivalent Grunt file written in Javascript does not throw this problem:

"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"
    ]);

};
+3
source share
1 answer

I do not see config.appin your configuration block, I can only see config.src, which contains the string ( "app").

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

Hope this helps.

+2

Source: https://habr.com/ru/post/1539829/


All Articles