咕噜声未定义
Grunt not defined
我是 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']);
};
这是我的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"
}
}
这是我收到的错误消息:
grunt build
Loading "Gruntfile.js"
tasks...ERROR >>
ReferenceError: grunt is not defined
Warning: Task "build" not found.Use--force to continue.
Aborted due to warnings.
各位大侠,我需要帮助。我在 windows 10 上工作,所以我在那里使用命令行。
module.exports = function(grunt) {
这是您定义 grunt
变量的地方。它是您创建的函数的参数。
但是你在这里尝试使用它:
require('time-grunt')(grunt);
这里:
require('jit-grunt')(grunt);
这是外部变量不存在的函数。
将那些行移到函数中。
我是 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']);
};
这是我的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"
}
}
这是我收到的错误消息:
grunt build
Loading "Gruntfile.js"
tasks...ERROR >> ReferenceError: grunt is not defined
Warning: Task "build" not found.Use--force to continue.
Aborted due to warnings.
各位大侠,我需要帮助。我在 windows 10 上工作,所以我在那里使用命令行。
module.exports = function(grunt) {
这是您定义 grunt
变量的地方。它是您创建的函数的参数。
但是你在这里尝试使用它:
require('time-grunt')(grunt);
这里:
require('jit-grunt')(grunt);
这是外部变量不存在的函数。
将那些行移到函数中。