Yeoman 和 Bower 没有添加 Bootstrap CSS(AngularJS 生成器)

Yeoman and Bower not adding Bootstrap CSS (AngularJS generator)

我正在关注 Yeoman 网页上的 codelab,到目前为止,我已经成功地跟进了(在我的开发环境运行过程中遇到了一些重大问题,但现在它没有 return 任何错误)。

所以我制作了我的项目文件夹和 运行 yo,选择了 AngularJS 和 运行 东西。很快进入这个过程,我得到提示 ? Overwrite package.json? 我用 y 回答并收到以下警告:

npm WARN package.json codelab@0.0.0 No license field.
npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency jasmine-core@* included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-phantomjs-launcher will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency phantomjs@>=1.9 included from karma-phantomjs-launcher will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency karma@~0.12.0 included from grunt-karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN optional dep failed, continuing fsevents@0.3.6

在那之后,它完成了它正在做的事情,所以我再次 运行 bower install 只是为了确定(因为 package.json 的事情),然后 grunt serve.现在 g运行t 说完成了,没有错误,但我的页面只加载 main.css。我强烈感觉 bootstrap.css 文件丢失了。 This is what it looks like, when the codelab instructions say it should look like this.

如果您需要有关生成的内容的更多信息,请点击此处 GitHub repository link

欢迎任何关于我做错了什么的见解(如果有的话)。

完成代码实验室后,我遇到了与您得到的结果完全相同的问题(警告和所有)。我不得不通过回滚到 Bootstrap 3.3.4.

来解决这个问题

只需编辑 bower.json 并将 Bootstrap 行更改为:

    "bootstrap": "3.3.4",

然后 运行 以下内容应该可以工作:

    bower install
    grunt serve

如果您坚持 shell,您只需输入:

bower install --save bootstrap#3.3.4
grunt serve

这将确保 Twitter Bootstrap 降级到更 Bower/yo-angular 友好的版本并将其保存为开发依赖项。 G运行t 将在其 'serve' 任务期间 运行 'wiredep' 并将 bootstrap.css 附加到项目的 index.html.

它对我也不起作用。我从这里得到了解决方案: https://github.com/twbs/bootstrap/issues/16663

我们通过覆盖我们的项目 bower.json 临时解决了这个问题。对我们来说它工作正常,但我们正在等待 Bootstrap.

的一些解决方案
"overrides":{
    "bootstrap" : {
         "main": [
            "less/bootstrap.less",
            "dist/css/bootstrap.css",
            "dist/js/bootstrap.js"
          ]
    }
  }

bower.json文件中,Bootstrap的依赖版本设置为:

"bootstrap": "^3.2.0",

默认情况下,即安装高于3.2.0的最新版本。 结果,安装了最新版本 3.3.5 并且中断了。

因此,删除 ^ 符号并替换:

"bootstrap": "^3.2.0",

与:

"bootstrap": "3.3.4",

不太理想,但我回滚到 Bootstrap 版本 3.3.4 并设置如下:

bower install --save bootstrap#3.3.4

bower_concat: {
  all: {
    dest: {
      'js': 'path/to/file/_bower.js',
      'css': 'path/to/file/_bower.css'
    }
  }
}