咕噜声没有定义

Grunt not defined

本文关键字:定义      更新时间:2023-09-26

我是Grunt的新手,一直在努力使这个工作:这是我的Gulpfile.js:

'use strict';
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt);
module.exports = function(grunt) {
    // Define the configuration for all the tasks
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    'app/scripts/{,*/}*.js'
                ]
            }
        }
    });
    grunt.registerTask('build', [
        'jshint'
    ]);
    grunt.registerTask('default', ['build']);
};

This my package.json:

{
  "name": "conFusion",
  "private": true,
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-contrib-jshint": "^1.0.0",
    "jit-grunt": "^0.10.0",
    "jshint-stylish": "^2.2.1",
    "time-grunt": "^1.4.0"
  },
  "engines": {
    "node": ">=0.10.0"
  }
}

这是我得到的错误信息:

繁重构建

加载"Gruntfile.js"

任务……错误>>参考错误:grunt没有定义

警告:未找到任务"build"。使用——force继续。

由于警告而中止。

伙计们,我需要帮助。我在windows 10上工作,所以我在那里使用命令行。
 module.exports = function(grunt) {

这就是您定义grunt变量的地方。它是您创建的函数的参数。

但是你试着在这里使用它:

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

:

 require('jit-grunt')(grunt);

在函数之外的,其中变量不存在。

行移到函数中