Grunt错误 - 警告:任务" bower-install"未找到

时间:2014-03-27 17:28:04

标签: angularjs twitter-bootstrap gruntjs bower

我刚刚尝试运行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来修复此错误,但我得到以下内容:n pm WARN package.json bootstrap@0.1.0 No README data

有没有人建议如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

请尝试以下方法:

  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. 之后添加此函数
  5. 确保已安装包" grunt-bower-install"。看看你的package.json。你应该在那里找到以下一行:

      

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

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

      

    npm install

         

    咕噜