我是Grunt世界的新手。
安装grunt-cli和所有依赖项之后,这是我的:/*
Grunt installation:
-------------------
npm install -g grunt-cli
npm install -g grunt-init
npm init (creates a `package.json` file)
Project Dependencies:
---------------------
npm install grunt --save-dev
npm install grunt-contrib-concat --save-dev
npm install grunt-contrib-watch --save-dev
Example Usage:
--------------
grunt -v
grunt release -v
*/
module.exports = function(grunt) {
"use strict";
grunt.initConfig({
concat: {
js: {
src: ['js/bootstrap.min.js', 'js/jquery-1.10.2.min.js'],
dest: 'build/js/scripts.js'
},
css: {
src: ['css/bootstrap.min.css', 'css/font-awesome.min.css'],
dest: 'build/css/styles.css'
}
},
watch: {
js: {
files: ['js/**/*.js'],
task: ['concat:js']
},
css: {
files: ['css/**/*.css'],
task: ['concat:css']
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasksNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['concat', 'watch']);
};
grunt
现在是测试部分,我试过运行Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
,我一直得到:
{{1}}
有人可以告诉我,我在这里做错了什么吗?
答案 0 :(得分:2)
由于拼写错误,似乎没有正确创建default
目标。尝试重命名
grunt.loadNpmTasksNpmTasks('grunt-contrib-watch');
到
grunt.loadNpmTasks('grunt-contrib-watch');
答案 1 :(得分:1)
遇到了类似的问题,并在下面的命令中尝试了安装节点模块的位置,该命令已为我解决了问题:
npm install --unsafe-perm