[英]Can't find bootstrap file in Angular app
I'm building an Angular on Rails app following a tutorial.我正在按照教程构建一个 Angular on Rails 应用程序。
I'm having problem with front-end dependencies in Rails project.我在 Rails 项目中遇到前端依赖问题。 I installed
bower
and sprockets
to install the dependencies like following:我安装了
bower
和sprockets
来安装依赖项,如下所示:
bower install angular angular-ui-router bootstrap --save
This should install bootstrap and other files.这应该安装引导程序和其他文件。 However, I get an rails error page saying:
但是,我收到一个 rails 错误页面说:
couldn't find file 'bootstrap/dist/css/bootstrap' with type 'text/css'
找不到类型为“text/css”的文件“bootstrap/dist/css/bootstrap”
Here is application.css
file:这是
application.css
文件:
*= require bootstrap/dist/css/bootstrap
*= require_tree .
*= require_self
Here is applicatiin.js
file:这是
applicatiin.js
文件:
//= require angular
//= require angular-rails-templates
//= require angular-ui-router
//= require_tree .
.bowerrc
file at vendor/assets/bower_components
: vendor/assets/bower_components
.bowerrc
文件:
{
"directory":"vendor/assets/bower_components"
}
Why isn't bower installing dependencies correctly?为什么凉亭不能正确安装依赖项? What am I doing wrong?
我究竟做错了什么?
I have used Bootstrap with Bower several times and I can walk you through the setup if that helps using the bower-rails
gem.我已经多次将 Bootstrap 与 Bower 一起使用,如果这有助于使用
bower-rails
gem,我可以引导您完成设置。
Gemfile
include gem 'bower-rails'
Gemfile
包含gem 'bower-rails'
bundle install
Bowerfile
include asset 'bootstrap'
Bowerfile
包含asset 'bootstrap'
bundle exec rake bower:install
application.css
include *= require bootstrap/dist/css/bootstrap
application.css
包含*= require bootstrap/dist/css/bootstrap
Restart your server and refresh the page and you should be good to go.重新启动您的服务器并刷新页面,您应该一切顺利。 Also in your
.bowerrc
file check and make sure your "directory"
is using the correct path.同样在您的
.bowerrc
文件中检查并确保您的"directory"
使用正确的路径。
I got the exact same issue - restarting the server solved it:我遇到了完全相同的问题 - 重新启动服务器解决了它:
rails s
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.