首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grunt - Warning:未找到任务"default“。使用--force继续

Grunt - Warning:未找到任务"default“。使用--force继续
EN

Stack Overflow用户
提问于 2014-12-29 05:25:03
回答 3查看 2.6K关注 0票数 1

刚开始尝试设置Grunt,但马上就遇到了问题。

代码语言:javascript
复制
Warning: Task "default" not found. Use --force to continue.

或完整的:

代码语言:javascript
复制
>> 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:

代码语言:javascript
复制
{
  "name": "BuildSanctuary",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-concat": "^0.5.0"
  }
}

Gruntfile.js

代码语言:javascript
复制
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']);

};
EN

回答 3

Stack Overflow用户

发布于 2014-12-29 05:30:58

为了解决这个问题,我将文件另存为UTF-8,它工作得很好。

票数 0
EN

Stack Overflow用户

发布于 2017-01-02 18:42:33

将文件保存为UTF-8格式会有所帮助。只需转到文本编辑器,在我的例子中,它就是超凡的文本。

使用编码-> UTF-8保存文件->

grunt能够找到默认任务。

票数 0
EN

Stack Overflow用户

发布于 2020-08-19 04:31:06

我能够通过安装grunt-cli来解决这个问题,我只安装了grunt,并且遇到了同样的错误。

代码语言:javascript
复制
npm install --save-dev grunt-cli

编辑:上面的内容让我更接近问题所在。我只是碰到了其他丢失的包。一旦我把它们都安装好了,它就能工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27680715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档