【问题标题】:Grunt Error - Warning: Task "bower-install" not foundGrunt 错误 - 警告:找不到任务“bower-install”
【发布时间】:2014-03-27 17:28:03
【问题描述】:

我刚刚尝试运行Angular-bootstrap 生成器并回答所有选项:

[?] What version of angular would you like to use? 1.2.15
[?] Which official angular modules would you need? animate, route
[?] Any third-party component you may require? bootstrap#~3.1.0
[?] Would you want me to support old versions of Internet Explorer (eg. before IE9)? nose arrow keys)
[?] Should I set up one of those JS preprocessors for you? none
[?] Should I set up one of those CSS preprocessors for you? sass
[?] What's the base name of your project? bootstrap
[?] Under which lincense your project shall be released? MIT
[?] Would you mind telling me your username on GitHub? mgcrea

一切运行良好,花花公子,但是当我尝试运行 grunt serve 或 grunt build 时,出现以下错误:Warning: Task "bower-install" not found. Use --force to continue.

我尝试运行 bower install & npm install 来修复此错误,但我得到以下信息:npm WARN package.json bootstrap@0.1.0 No README data

有人对我如何解决这个问题有任何建议吗?

【问题讨论】:

  • 为了克服这个问题,我刚刚在运行角度生成器后手动添加了模块
  • 您真的应该将答案发布为“答案”而不是“评论”
  • 这不是一个答案,这只是他用来继续他自己的工作的一种变通方法……而这种变通方法并不能回答这个问题

标签: angularjs twitter-bootstrap gruntjs bower


【解决方案1】:

请尝试以下方法:

  1. 尝试使用“bowerInstall” - 而不是“bower-install”,因为此选项已在更高版本中重命名 (见https://github.com/mgcrea/generator-angular-bootstrap/issues/2

  2. 确保从应用的根目录运行 bowerInstall

  3. 看看你的 Gruntfile.js - 有没有函数“bowerInstall”?如果没有,只需添加它:

    bowerInstall: {
        target: {
    
            // Point to the files that should be updated when
            // you run `grunt bower-install`
            src: [
                'app/views/**/*.html',   // .html support...
                'app/*.html',   // .html support...
            ],
    
            // Optional:
            // ---------
            cwd: '',
            dependencies: true,
            devDependencies: false,
            exclude: [],
            fileTypes: {},
            ignorePath: '',
            overrides: {}
        }
    }
    

    例如,您可以在函数 filerev 之后添加此函数:{....}

  4. 确保您已安装软件包“grunt-bower-install”。看看你的 package.json。您应该在那里找到以下行:

    "grunt-bower-install": "^1.6.0",

    如果没有,只需添加它然后运行:

    npm 安装

    咕哝

【讨论】:

  • 在执行 grunt 之前在本地运行“npm install”命令是我缺少的步骤。
猜你喜欢
  • 1970-01-01
  • 2015-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-13
  • 1970-01-01
  • 2015-10-25
相关资源
最近更新 更多