刚刚开始使用grunt,当我运行时,grunt我得到了这个错误
Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: grunt is not defined
Run Code Online (Sandbox Code Playgroud)
这是我的Gruntfile.js
module.exports = function(grunt){
'use strict';
};
Run Code Online (Sandbox Code Playgroud)
我突然发生在我身上,
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
sass: {
dist: {
files: {
'style.css': 'style.scss'
},
options: {
includePaths: ['css/'],
outputStyle: 'nested'
}
}
},
});
grunt.loadNpmTasks('grunt-sass');
grunt.registerTask('sass', ['sass']);
};
Run Code Online (Sandbox Code Playgroud)
确保loadNpmTasks和registerTask命令在module.export中,如果它们超出了该闭包的范围,则grunt将不会被定义,因此它将失败
不完全确定原因,但这解决了这个问题:
'use strict';
module.exports = function(grunt){
};
Run Code Online (Sandbox Code Playgroud)