咕噜声未定义 - AngularJs
grunt is not defined - AngularJs
这是我在 grunt 中的第一次测试:)。无论如何,我想使用不同的 grunt 模块测试我的 javasrcipt 代码。它们都已安装,您可以在名为 package.json.
的 json 文件中看到它们
{
"name": "LarissaCity",
"private": true,
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-jshint": "^1.1.0",
"jit-grunt": "^0.10.0",
"jshint-stylish": "^2.2.1",
"time-grunt": "^1.4.0"
},
"engines": {
"node": ">=0.10.0"
}
}
接下来我有一个名为 Gruntfile.js 的文件。在它里面使用安装的模块来测试我的 javascript 代码。所以.
'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);
// 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']);
当我在 cmd 中输入 grunt 时,会出现这个问题。
Loading "Gruntfile.js" tasks...ERROR
ReferenceError: grunt is not defined
所以 Gruntfile.js 中可能有问题。有任何想法吗?
谢谢,
西奥
您必须在 gruntfile.js
的下方块中编写代码
module.exports = function(grunt){
//Your code here
}
这是我在 grunt 中的第一次测试:)。无论如何,我想使用不同的 grunt 模块测试我的 javasrcipt 代码。它们都已安装,您可以在名为 package.json.
的 json 文件中看到它们{
"name": "LarissaCity",
"private": true,
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-jshint": "^1.1.0",
"jit-grunt": "^0.10.0",
"jshint-stylish": "^2.2.1",
"time-grunt": "^1.4.0"
},
"engines": {
"node": ">=0.10.0"
}
}
接下来我有一个名为 Gruntfile.js 的文件。在它里面使用安装的模块来测试我的 javascript 代码。所以.
'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);
// 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']);
当我在 cmd 中输入 grunt 时,会出现这个问题。
Loading "Gruntfile.js" tasks...ERROR
ReferenceError: grunt is not defined
所以 Gruntfile.js 中可能有问题。有任何想法吗?
谢谢,
西奥
您必须在 gruntfile.js
的下方块中编写代码 module.exports = function(grunt){
//Your code here
}