刚开始尝试设置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']);
};
答案 0 :(得分:0)
为了解决这个问题,我将文件保存为UTF-8并且工作正常。
答案 1 :(得分:0)
以UTF-8保存文件会有所帮助。 在我的案例中,只需转到文本编辑器,即它的崇高文本。
档案 - >使用编码保存 - > UTF-8
grunt能够找到默认任务。
答案 2 :(得分:0)
我能够通过安装grunt-cli来解决这个问题,我只安装了grunt-cli,并且遇到了同样的错误。
npm install --save-dev grunt-cli
编辑: 以上只是让我更接近问题。我碰到了其他丢失的包裹。一旦我把它们全部安装好,就可以了。