剛開始嘗試設置Grunt,但立即出現問題。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']);
};
任何幫助?
我很難懷疑它與上面粘貼的代碼的編碼有關!錯誤說「'(Unexpected token c).'」在字符串外某個地方一定有字符「c」,或者在整個文件中有一些完全不是JSON的字符。 –
我搜索了四周,發現其他人有同樣的問題。其他地方的建議表示將該文件保存爲UTF-8,因爲標準編碼增加了一些額外的內容......如果不誠實,它會超出我的範圍。但改變保存類型固定它。 – Lovelock
之前是什麼編碼?這對你的答案會非常有幫助(對於有同樣問題的其他人)。 :) –