Loading "gruntfile.js" tasks...ERROR >> ReferenceError: grunt is not defined
Loading "gruntfile.js" tasks...ERROR >> ReferenceError: grunt is not defined
我的代码有问题。
我在 concole 中写道:grunt connect
这是错误消息:
正在加载 "gruntfile.js" 个任务...错误
ReferenceError: grunt is not defined
Warning: Task "connect" not found. Use --force to continue.
由于警告而中止。
这是我的 gruntfile.js 文件:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
uses_defaults: {}
}
});
// Load Grunt plugins
grunt.loadNpmTasks('');
// Default task(s).
grunt.registerTask('default', []);
};
// Load Grunt plugins
grunt.loadNpmTasks('grunt-contrib-connect');
我的代码有什么问题?
为什么找不到连接任务?
"Every Gruntfile (and gruntplugin) uses this basic format, and all of your Grunt code must be specified inside this function:"-https://gruntjs.com/getting-started
module.exports = function(grunt) {
// Do grunt-related things in here
};
将 grunt.loadNpmTasks('grunt-contrib-connect');
移动到此函数中应该可以解决它。
我的代码有问题。
我在 concole 中写道:grunt connect
这是错误消息:
正在加载 "gruntfile.js" 个任务...错误
ReferenceError: grunt is not defined Warning: Task "connect" not found. Use --force to continue.
由于警告而中止。
这是我的 gruntfile.js 文件:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
uses_defaults: {}
}
});
// Load Grunt plugins
grunt.loadNpmTasks('');
// Default task(s).
grunt.registerTask('default', []);
};
// Load Grunt plugins
grunt.loadNpmTasks('grunt-contrib-connect');
我的代码有什么问题? 为什么找不到连接任务?
"Every Gruntfile (and gruntplugin) uses this basic format, and all of your Grunt code must be specified inside this function:"-https://gruntjs.com/getting-started
module.exports = function(grunt) {
// Do grunt-related things in here
};
将 grunt.loadNpmTasks('grunt-contrib-connect');
移动到此函数中应该可以解决它。