Javascript “装载”;Gruntfile.js“;任务…错误 “严格使用”; module.exports=函数(grunt){ 要求('load-grunt-tasks')(grunt); 要求(“时间咕噜”)(咕噜); 变量配置={ 应用程序:'app', 地区:'dist' } grunt.initConfig({ config:config, 副本:{ dist_html:{ src:“/index.html”, dest:“/index.html” }, 地区:{ src:'/js/index.js',, dest:“/js/index.js” } }, 清洁:{ 地区:{ src:“/index.html” } } });}}

Javascript “装载”;Gruntfile.js“;任务…错误 “严格使用”; module.exports=函数(grunt){ 要求('load-grunt-tasks')(grunt); 要求(“时间咕噜”)(咕噜); 变量配置={ 应用程序:'app', 地区:'dist' } grunt.initConfig({ config:config, 副本:{ dist_html:{ src:“/index.html”, dest:“/index.html” }, 地区:{ src:'/js/index.js',, dest:“/js/index.js” } }, 清洁:{ 地区:{ src:“/index.html” } } });}},javascript,gruntjs,Javascript,Gruntjs,我在cmd中输入了“grunt copy”,但它出现了错误。我很快就开始学习grunt,如何解决这个问题?我需要帮助,思考。你需要注册任务才能在cmd中使用它 例如: 'use strict'; module.exports = function (grunt) { require('load-grunt-tasks')(grunt); require('time-grunt')(grunt); var config = { app:'app', dist:'dist' }


我在cmd中输入了“grunt copy”,但它出现了错误。我很快就开始学习grunt,如何解决这个问题?我需要帮助,思考。

你需要注册任务才能在cmd中使用它

例如:

'use strict';

module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);

require('time-grunt')(grunt);

var config = {
    app:'app',
    dist:'dist'
}

grunt.initConfig({
    config: config,

    copy: {
        dist_html: {
            src:'<%= config.app %>/index.html',
            dest:'<%= config.dist %>/index.html'
        },
        dist_js: {
            src:'<%= config.app %>/js/index.js',
            dest:'<%= config.dist %>/js/index.js'
        }
    },

    clean: {
        dist: {
            src: '<%= config.dist %>/index.html'
        }
    }
});}}

您需要注册任务才能在cmd中使用它

例如:

'use strict';

module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);

require('time-grunt')(grunt);

var config = {
    app:'app',
    dist:'dist'
}

grunt.initConfig({
    config: config,

    copy: {
        dist_html: {
            src:'<%= config.app %>/index.html',
            dest:'<%= config.dist %>/index.html'
        },
        dist_js: {
            src:'<%= config.app %>/js/index.js',
            dest:'<%= config.dist %>/js/index.js'
        }
    },

    clean: {
        dist: {
            src: '<%= config.dist %>/index.html'
        }
    }
});}}

您只配置了要使用的路径。您应该创建如下任务:

grunt.registerTask(taskName, [description, ] taskFunction)
这里有关于grunt任务的更多信息:

您只配置了要使用的路径,您应该创建如下任务:

grunt.registerTask(taskName, [description, ] taskFunction)
这里有关于grunt任务的更多信息: