刚开始尝试设置Grunt,但马上就遇到了问题。
Warning: Task "default" not found. Use --force to continue.或完整的:
>> Error: Unable to parse "package.json" file (Unexpected token c).
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.我遵循这个指南:http://24ways.org/2013/grunt-is-not-weird-and-hard/
这两个文件是:
package.json:
{
"name": "BuildSanctuary",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "^0.5.0"
}
}Gruntfile.js
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: [
'public_html/js/*.js', // All JS in the libs folder
],
dest: 'public_html/js/production.js',
}
}
});
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat']);
};发布于 2014-12-29 05:30:58
为了解决这个问题,我将文件另存为UTF-8,它工作得很好。
发布于 2017-01-02 18:42:33
将文件保存为UTF-8格式会有所帮助。只需转到文本编辑器,在我的例子中,它就是超凡的文本。
使用编码-> UTF-8保存文件->
grunt能够找到默认任务。
发布于 2020-08-19 04:31:06
我能够通过安装grunt-cli来解决这个问题,我只安装了grunt,并且遇到了同样的错误。
npm install --save-dev grunt-cli编辑:上面的内容让我更接近问题所在。我只是碰到了其他丢失的包。一旦我把它们都安装好了,它就能工作了。
https://stackoverflow.com/questions/27680715
复制相似问题