Gruntjs 咕哝着跑茉莉花
我正在尝试用grunt运行jasmine测试,但是我收到了这个错误消息,我不确定下一步如何解决它。下面是我尝试用grunt运行jasmine时的实际错误消息Gruntjs 咕哝着跑茉莉花,gruntjs,jasmine,grunt-contrib-jasmine,Gruntjs,Jasmine,Grunt Contrib Jasmine,我正在尝试用grunt运行jasmine测试,但是我收到了这个错误消息,我不确定下一步如何解决它。下面是我尝试用grunt运行jasmine时的实际错误消息 $ grunt jasmine:all Loading "jasmine.js" tasks...ERROR >> TypeError: Cannot read property '_' of undefined Loading "Gruntfile.js" tasks...ERROR >> TypeError: C
$ grunt jasmine:all
Loading "jasmine.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Warning: Cannot read property 'namespace' of undefined Use --force to continue.
Aborted due to warnings.
Fatal error: Cannot read property 'exit' of undefined
/Users/user1/dev/app/node_modules/grunt/lib/grunt/fail.js:57
grunt.util.exit(typeof errcode === 'number' ? errcode : fail.code.FATAL_ERROR);
^
TypeError: Cannot read property 'exit' of undefined
at Object.fail.fatal (/Users/user1/dev/app/node_modules/grunt/lib/grunt/fail.js:57:13)
at process.uncaughtHandler (/Users/user1/dev/app/node_modules/grunt/lib/grunt.js:130:10)
at emitOne (events.js:77:13)
at process.emit (events.js:169:7)
at process._fatalException (node.js:234:26)
我下一步该怎么解决这个问题呢
添加Grunfile
module.exports=函数(grunt){
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
//所有配置都在这里
jshint:{
选项:{
记者:require('jshint-style')
},
构建:['Gruntfile.js','src/***.js']
},
丑陋的:{
选项:{
横幅:'/*\n\n*/\n'
},
建造:{
档案:{
'dist/js/bundle.min.js':
[
'bower_components/angular/angular.js'
]
}
}
},
减:{
建造:{
档案:{
'dist/css/pretty.css':
[
'src/css/pretty.less'
]
}
}
},
cssmin:{
选项:{
横幅:'/*\n\n*/\n'
},
建造:{
档案:{
“dist/css/style.min.css”:
[
“src/css/style.css”
]
}
}
},
观察:{
样式表:{
文件:['src/***/.css','src/***/.less'],
任务:['less','cssmin']
},
脚本:{
文件:“src/***.js”,
任务:['jshint','uglify']
}
}
});
//加载grunt插件
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks(“grunt-contrib-uglify”);
grunt.loadNpmTasks(“grunt-contrib-less”);
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks(“grunt-contrib-watch”);
grunt.loadNpmTasks(“grunt-contrib-jasmine”);
registerTask('default',['jshint','uglify','cssmin','less']);
};
Post your Gruntfile.js在Gruntfile
Post your Gruntfile.js中看不到您的jasmine
任务
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//all configuration goes here
jshint: {
options: {
reporter: require('jshint-stylish')
},
build: ['Gruntfile.js','src/**/*.js']
},
uglify: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n */\n'
},
build: {
files: {
'dist/js/bundle.min.js' :
[
'bower_components/angular/angular.js'
]
}
}
},
less: {
build: {
files: {
'dist/css/pretty.css' :
[
'src/css/pretty.less'
]
}
}
},
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n */\n'
},
build: {
files: {
'dist/css/style.min.css' :
[
'src/css/style.css'
]
}
}
},
watch: {
stylesheets: {
files: ['src/**/*.css', 'src/**/*.less'],
tasks: ['less', 'cssmin']
},
scripts: {
files: 'src/**/*.js',
tasks: ['jshint', 'uglify']
}
}
});
//loads grunt plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.registerTask('default', ['jshint', 'uglify', 'cssmin', 'less']);
};