Gruntjs grunt不会在我的项目上运行,哪个默认任务?

Gruntjs grunt不会在我的项目上运行,哪个默认任务?,gruntjs,Gruntjs,我试图运行grunt以获得SASS和其他一些东西来编译我的项目(其他人创建的项目),但是我不断得到以下错误: 警告:未找到任务“默认值”。使用--force继续。 由于警告而中止。 我不明白它指的是哪个“默认”任务。我继承的grunt文件如下所示: module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.j

我试图运行grunt以获得SASS和其他一些东西来编译我的项目(其他人创建的项目),但是我不断得到以下错误:

警告:未找到任务“默认值”。使用--force继续。 由于警告而中止。

我不明白它指的是哪个“默认”任务。我继承的grunt文件如下所示:

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

              concat: {
                options: {
                  separator: ';'
                },
                dev: {
                  src: ['www/_assets/js/vendor-concat/*.js', 'www/_assets/js/*.js', '!www/_assets/js/prototype.js', '!www/_assets/js/scripts.js', '!www/_assets/js/scripts.min.js'],
                  dest: 'www/_assets/js/scripts.js'
                }
              },
              uglify: {
                dist: {
                  files: {
                    'www/_assets/js/scripts.min.js': ['www/_assets/js/scripts.js']
                  }
                }
              },
              jshint: {
                files: ['Gruntfile.js'],
                options: {
                  // options here to override JSHint defaults
                  globals: {
                    jQuery: true,
                    console: true,
                    module: true,
                    document: true
                  }
                }
              },
              modernizr: {
                dist: {
                  // [REQUIRED] Path to the build you're using for development.
                  "devFile" : "www/_assets/js/vendor/modernizr-2.7.1.js",

                  // [REQUIRED] Path to save out the built file.
                  "outputFile" : "www/_assets/js/vendor/modernizr-custom.js"
                }
              },
              imageoptim: {
                dev: {
                  src: ['www/_assets/img']
                }
              },
              sass: {
                dev: {
                  options: {
                    includePaths: ['www/_assets/scss'],
                    outputStyle: 'compressed',
                    sourceMap: true
                  },
                  files: {
                    'www/_assets/css/main.css' : 'www/_assets/scss/main.scss',
                    'www/_assets/css/main-ie8.css' : 'www/_assets/scss/main-ie8.scss'
                  }
                }
              },
              assemble: {
                options: {
                  flatten: false,
                  expand: true,

                  assets: 'www/_assets',

                  layout: 'default.hbs',
                  layoutdir: 'www/_templates/layouts',

                  partials: ['www/_templates/partials/*.hbs'],
                  data: ['www/_templates/data/*.json']
                },

                dev: {
                  files: [
                    {expand: true, cwd: 'www/_templates/pages/', src: '**/*.hbs', dest: 'www/', ext: '.html'}
                  ]
                }
              },
              watch: {
                options: {
                  livereload: true,
                  spawn: false
                },
                css: {
                  files: ['www/_assets/scss/**/*.scss'],
                  tasks: ['sass']
                },
                js: {
                  files: ['www/_assets/js/**/*.js', '!www/_assets/js/scripts.min.js', '!www/_assets/js/scripts.js'],
                  tasks: ['jshint', 'concat:dev']
                },
                hbs: {
                  files: ['www/_templates/{,*/}*.hbs', 'www/_templates/{,*/*/}*.hbs', 'www/_templates/{,*/*/*/}*.hbs'],
                  tasks: ['assemble']
                },
                html: {
                  files: ['www/email.html']
                }
              },
              copyto: {
                prototype: {
                  files: [
                    {cwd: 'www/', src: ['**/*'], dest: 'prototype/'}
                  ],
                  options: {
                    ignore: [
                      'www/_assets/scss{,/**/*}',
                      'www/_assets/js{,/**/*}',
                      '!www/_assets/js/vendor{,/**/*}',
                      '!www/_assets/js/scripts.min.js',
                      '!www/_assets/js/prototype.js',
                      'www/_templates{,/**/*}',
                      'www/z-backups{,/**/*}',
                      'www/_assets/css/*.map'
                    ]
                  }
                },
                beta: {
                  files: [
                    {cwd: 'prototype/_assets/', src: ['**/*'], dest: '_beta-sln/Beta/src/SFA.as.Web.Candidate/Content/_assets/'}
                  ],
                  options: {
                    ignore: [
                      'prototype/_assets/video{,/**/*}',
                      'prototype/_assets/js/prototype.js'
                    ]
                  }
                },
                sprint: {
                  files: [
                    {cwd: 'prototype/', src: ['**/*'], dest: 'sprint/'}
                  ]
                },
                dist: {
                  files: [
                    {cwd: 'www/', src: ['**/*'], dest: 'dist/'}
                  ],
                  options: {
                    ignore: [
                      'www/_assets/scss{,/**/*}',
                      'www/_assets/css/*.map',
                      'www/_assets/video{,/**/*}',
                      'www/_assets/js/plugins{,/**/*}',
                      'www/_assets/js/interactions.js',
                      'www/_assets/js/scripts.js',
                      'www/_templates{,/**/*}',
                      'www/*.html',
                      '!www/index.html',
                      'www/z-backups{,/**/*}'
                    ]
                  }
                }
              },
              clean: {
                prototype: {
                  src: [ 'prototype/' ]
                },
                sprint: {
                  src: [ 'sprint/' ]
                },
                dist: {
                  src: [ 'dist/' ]
                }
              },
              replace: {
                map: {
                  src: ['www/_assets/css/*.css'],
                  overwrite: true,
                  replacements: [{
                    from: 'sourceMappingURL=main.css.map',
                    to: 'Map removed'
                  },{
                    from: 'sourceMappingURL=main-ie8.css.map',
                    to: 'Map removed'
                  }]
                },
                scripts: {
                  src: ['www/apprentice/*.html', 'www/test/apprentice/*.html', 'www/trainee/*.html', 'www/employer/*.html', 'www/*.html'],
                  overwrite: true,
                  replacements: [{
                    from: 'scripts.js',
                    to: 'scripts.min.js'
                  }]
                }
              },
              prettify: {
                options: {
                  indent: 2,
                  wrap_line_length: 78,
                  brace_style: 'expand',
                },
                // Specify a number to padcomments
                dist: {
                  files: [
                    {expand: true, cwd: 'dist/', src: ['apprentice/*.html', 'trainee/*.html', 'employer/*.html', '*.html'], dest: 'dist/', ext: '.html'}
                  ]
                },
                prototype: {
                  files: [
                    {expand: true, cwd: 'prototype/', src: ['apprentice/*.html', 'trainee/*.html', 'employer/*.html', '*.html', '!pattern-library.html'], dest: 'prototype/', ext: '.html'}
                  ]
                }
              },
              devUpdate: {
                main: {
                  options: {
                    updateType: 'report', //just report outdated packages
                    reportUpdated: false, //don't report already updated packages
                    semver: true, //use package.json semver rules when updating
                    packages: { //what packages to check
                      devDependencies: true, //only devDependencies
                      dependencies: false
                    },
                    packageJson: null //find package.json automatically
                  }
                }
              },
              browserSync: {
                dev: {
                  bsFiles: {
                    src : [
                      'www/_assets/css/*.css',
                      'www/_assets/js/scripts.js',
                      'www/**/*.html'
                      ]
                  },
                  options: {
                    ghostMode: {
                      clicks: true,
                      scroll: true,
                      links: true,
                      forms: true
                      },
                    watchTask: true,
                    server: {
                      baseDir: "www"
                    }
                  }
                }
              },
              connect: {
                server: {
                  options: {
                    port: 7000,
                    base: 'www',
                    livereload: true,
                    open: true
                  }
                }
              },
              uncss: {
                offline: {
                  options: {
                    // csspath      : 'www/_assets/css/',
                    // urls         : ['http://localhost:/mypage', '...'], // Deprecated
                    timeout      : 1000,
                  },
                  files: {
                    'www/offline/offline.css': ['www/offline/maintenance.html']
                  }
                }
              }

            });

            [
              'assemble',
              'grunt-modernizr',
              'grunt-contrib-imagemin',
              'grunt-imageoptim',
              'grunt-contrib-uglify',
              'grunt-contrib-jshint',
              'grunt-sass',
              'grunt-uncss',
              'grunt-criticalcss',
              'grunt-contrib-concat',
              'grunt-text-replace',
              'grunt-contrib-watch',
              'grunt-copy-to',
              'grunt-contrib-clean',
              'grunt-contrib-compress',
              'grunt-pngmin',
              'grunt-browser-sync',
              'grunt-dev-update',
              'grunt-contrib-connect',
              'grunt-prettify'
            ].forEach(function (task) {
              grunt.loadNpmTasks(task);
            });

            grunt.registerTask('images', ['imageoptim']);

            grunt.registerTask('modern', ['modernizr']);

            grunt.registerTask('offline', ['uncss:offline']);

            grunt.registerTask('dev', ['jshint', 'concat:dev', 'sass', 'assemble', 'connect', 'watch']);

            grunt.registerTask('sync', ['jshint', 'concat:dev', 'sass', 'assemble', 'browserSync', 'watch']);

            grunt.registerTask('proto', ['uglify:dist', 'replace:map', 'clean:prototype', 'replace:scripts', 'copyto:prototype', 'prettify:prototype']);

            grunt.registerTask('sprint', ['clean:sprint', 'copyto:sprint']);

            grunt.registerTask('dist', ['uglify:dist', 'replace:map', 'clean:dist', 'replace:scripts', 'copyto:dist', 'prettify:dist']);

            grunt.registerTask('beta', ['copyto:beta']);


          };
由于这不是我自己创造的,我不愿意去打破它,但有什么突出的地方吗?我见过类似的问题,但由于grunt文件需要改变,因此很难找到正确的答案


非常感谢

由于文件没有默认任务,您必须创建它或使用定义的任务之一运行grunt:

> grunt dev
或者在Gruntfile.js中添加默认任务

grunt.registerTask('default',['dev']);

有关更多信息,请参阅

嘿,非常感谢!它很快就成功了,我认为我的项目已经设置了默认任务,我需要更多地了解这一点,因为我不知道“dev”在这个上下文中代表什么。“dev”是您在以下行中定义的任务:`grunt.registerTransk('dev',['jshint','concat:dev','sass','assemble','connect watch']);`所以它只是上面在initConfig中定义的其他任务(或队列)的数组