twitter-bootstrap Yeoman 和 Bower 没有添加 Bootstrap CSS(AngularJS 生成器)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30946498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Yeoman and Bower not adding Bootstrap CSS (AngularJS generator)
提问by Miha ?u?ter?i?
I am following along a codelabon the Yeoman webpage, and so far I've managed to follow along (with a few major hiccups getting my development environment going, but now it doesn't return any errors).
我正在关注Yeoman 网页上的一个代码实验室,到目前为止我已经设法跟进(在让我的开发环境运行时遇到了一些主要问题,但现在它没有返回任何错误)。
So I made my project folder and ran yo, selected AngularJS and run the thing. Fairly soon into the process I got a prompt ? Overwrite package.json?I answered with yand got the following warnings:
所以我创建了我的项目文件夹并运行yo,选择 AngularJS 并运行它。很快我就收到了一个提示,? Overwrite package.json?我回答y了这个问题,并收到了以下警告:
npm WARN package.json [email protected] 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 [email protected]
After that, it finished what it was doing, so I ran bower installagain just to be sure (because of the package.json thing), and then grunt serve. Now grunt says done, without errors, but my page only loads main.css. I have a strong feeling the bootstrap.cssfile is missing. Thisis what it looks like, when the codelab instructions say it should look like this.
在那之后,它完成了它正在做的事情,所以我bower install再次运行以确保(因为 package.json 的事情),然后grunt serve. 现在 grunt 说完成了,没有错误,但我的页面只加载main.css. 我有一种强烈的感觉,bootstrap.css文件丢失了。这是它的样子,当 codelab 说明说它应该是这样的。
If you need further information on what was generated, here's a GitHub repository link.
如果您需要有关生成内容的更多信息,请访问GitHub 存储库链接。
Any insight on what I'm doing wrong (if anything) is welcome.
欢迎任何关于我做错了什么(如果有的话)的见解。
回答by chipzilla
After doing the codelab I had exactly the same problem with the same result as you are getting (warnings and all). I had to just work around the issue by rolling back to Bootstrap 3.3.4.
完成代码实验室后,我遇到了与您得到的结果完全相同的问题(警告和所有)。我不得不通过回滚到 Bootstrap 3.3.4 来解决这个问题。
Just edit bower.json and change the Bootstrap line to:
只需编辑 bower.json 并将 Bootstrap 行更改为:
"bootstrap": "3.3.4",
Then run the following and it should work:
然后运行以下命令,它应该可以工作:
bower install
grunt serve
回答by codesnooker
It didn't work for me either. I got a solution from here: https://github.com/twbs/bootstrap/issues/16663
它对我也不起作用。我从这里得到了一个解决方案:https: //github.com/twbs/bootstrap/issues/16663
We fixed this issue temporary by overriding our project bower.json. For us it works fine, but we are waiting for some solution from Bootstrap.
我们通过覆盖我们的项目临时解决了这个问题bower.json。对我们来说它工作正常,但我们正在等待 Bootstrap 的一些解决方案。
"overrides":{
"bootstrap" : {
"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js"
]
}
}
回答by Glenn Batuyong
If you stick to a shell, you can just type:
如果您坚持使用外壳,则只需键入:
bower install --save bootstrap#3.3.4
grunt serve
That will ensure that Twitter Bootstrap gets downgraded to a more Bower/yo-angular friendly version and save it as a dev dependency. Grunt will then run 'wiredep' during its 'serve' task and append the bootstrap.css in your project's index.html.
这将确保 Twitter Bootstrap 降级为更适合 Bower/yo-angular 的版本,并将其保存为开发依赖项。然后 Grunt 将在其“服务”任务期间运行“wiredep”,并将 bootstrap.css 附加到您项目的 index.html 中。
回答by burakhan alkan
In the bower.jsonfile, the dependency version of Bootstrap is set as:
在bower.json文件中,Bootstrap的依赖版本设置为:
"bootstrap": "^3.2.0",
By default, that means install the latest version higher than 3.2.0. As a result, the latest version 3.3.5 is installed and that breaks.
默认情况下,这意味着安装高于 3.2.0 的最新版本。结果,安装了最新版本 3.3.5 并且中断了。
So, remove the ^sign and replace:
因此,删除^标志并替换:
"bootstrap": "^3.2.0",
with:
和:
"bootstrap": "3.3.4",
回答by CR Rollyson
It is not ideal, but I rolled back to Bootstrap version 3.3.4 and setting up like this:
这并不理想,但我回滚到 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'
}
}
}

