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

Mih*_*šič 26 twitter-bootstrap angularjs yeoman bower yeoman-generator-angular

我沿着以下代码实验室对约曼网页,到目前为止,我已经成功地跟着一起(有以下几个主要打嗝让我的开发环境中去,但现在它不返回任何错误).

所以我制作了我的项目文件夹并运行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
Run Code Online (Sandbox Code Playgroud)

之后,它完成了它正在做的事情,所以我bower install再次运行只是为了确定(因为package.json的事情),然后grunt serve.现在grunt说完了,没有错误,但我的页面只加载main.css.我强烈感觉bootstrap.css文件丢失了.就是它的样子,当codelab指令说它应该是这样的.

如果您需要有关生成内容的更多信息,请参阅GitHub存储库链接.

任何关于我做错事(如果有的话)的见解都是受欢迎的.

chi*_*lla 57

在完成codelab之后,我遇到的问题与你得到的结果完全相同(警告和所有).我不得不通过回滚到Bootstrap 3.3.4来解决这个问题.

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

    "bootstrap": "3.3.4",
Run Code Online (Sandbox Code Playgroud)

然后运行以下它应该工作:

    bower install
    grunt serve
Run Code Online (Sandbox Code Playgroud)

  • 我认为这意味着要求高于1.3.0.所以对于bootstrap来说它是"bootstrap":"^ 3.2.0",意味着安装任何高于3.2.0的东西.因此它会安装最新的3.3.5,但不起作用.将它设置为3.3.4而没有^表示只安装此版本,没有更高的. (4认同)
  • 在编辑之前,我的引导线在版本号之前有一个`^`(就像这个`"angular":"^ 1.3.0"`).有什么想法,如果我应该在bootstrap版本之前把它放回去?除此之外,该网站现在看起来应该是这样,所以我终于准备继续使用codelab了.谢谢 (2认同)

cod*_*ker 25

它对我也没有用.我从这里得到了一个解决方案:https: //github.com/twbs/bootstrap/issues/16663

我们通过覆盖我们的项目来临时修复此问题bower.json.对我们来说它工作正常,但我们正在等待Bootstrap的一些解决方案.

"overrides":{
    "bootstrap" : {
         "main": [
            "less/bootstrap.less",
            "dist/css/bootstrap.css",
            "dist/js/bootstrap.js"
          ]
    }
  }
Run Code Online (Sandbox Code Playgroud)


小智 10

如果您坚持使用shell,则只需键入:

bower install --save bootstrap#3.3.4
grunt serve
Run Code Online (Sandbox Code Playgroud)

这将确保Twitter Bootstrap降级为更加Bower/yo-angular友好版本并将其保存为dev依赖项.然后,Grunt将在"服务"任务期间运行"wiredep",并将bootstrap.css附加到项目的index.html中.