admin管理员组文章数量:1323023
I'm new to the Grunt world.
After installing grunt-cli, and all the dependencies, here is my : Gruntfile.js
/*
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']);
};
Result
Now the testing part, I tried run grunt
, I kept getting :
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
Can someone please tell me what did I do wrong here ?
I'm new to the Grunt world.
After installing grunt-cli, and all the dependencies, here is my : Gruntfile.js
/*
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']);
};
Result
Now the testing part, I tried run grunt
, I kept getting :
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
Can someone please tell me what did I do wrong here ?
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked May 11, 2015 at 15:21 code-8code-8 58.8k120 gold badges390 silver badges666 bronze badges 1-
It doesn't understand
grunt.loadNpmTasksNpmTasks
. It should begrunt.loadNpmTasks
like the previous one. I think it's just confused. – Andy Commented May 11, 2015 at 15:26
2 Answers
Reset to default 3It looks like the default
target is not being created properly due to a typo. Try renaming
grunt.loadNpmTasksNpmTasks('grunt-contrib-watch');
to
grunt.loadNpmTasks('grunt-contrib-watch');
Have faced similar issues and tried below mand where your node modules is installed which resolved issue for me:
npm install --unsafe-perm
本文标签: javascriptLoading quotGruntfilejsquot tasksERROR while running gruntStack Overflow
版权声明:本文标题:javascript - Loading "Gruntfile.js" tasks...ERROR while running `grunt` - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742111254a2421266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论