Rails: File to import not found or unreadable: “bootstrap”

前端 未结 8 1416
野的像风
野的像风 2021-02-19 14:03

I am relatively new to programming, therefore I hope that the question is not absolutely stupid.

I got a problem concerning my rails app.

I try to use bootstrap.

相关标签:
8条回答
  • I got the same problem of "File to import not found or unreadable: bootstrap" in my scss file. I just solved by adding require statement of "bootstrap-sass" to config.ru file. My config.ru is like the following.

    # This file is used by Rack-based servers to start the application.
    
    require ::File.expand_path('../config/environment',  __FILE__)
    require 'bootstrap-sass' #require statement of bootstrap-sass
    run Rails.application
    
    0 讨论(0)
  • 2021-02-19 14:17

    Had the same issue in a new application, but restarting the development server solved the issue.

    0 讨论(0)
  • 2021-02-19 14:18

    facing same problem. I rename custom.css.scss to custom.css and I specified version of ruby in Gemfile. and bundle install . in my case: ruby '2.0.0'

    0 讨论(0)
  • 2021-02-19 14:22

    I had a similar issue, and I changed the file type from css to scss. I bet if you erase '.css' from your file name it'll work.

    0 讨论(0)
  • 2021-02-19 14:22

    I had this same problem, solved by fixing bootstrap-sass and sass-rails versions to:

    gem 'sass-rails', '~> 3.2'
    gem 'bootstrap-sass', '~> 2.3.1.0'
    

    And then bundle install and server restart.

    0 讨论(0)
  • 2021-02-19 14:28

    I had a similar issue when working on a Rails 6 application with Bootstrap 4.

    The issue was that I did not specify the node modules full path of the bootstrap.scss file in my app/assets/stylesheets/application.scss file.

    After installing Bootstrap 4 and its dependencies using this command:

    yarn add bootstrap jquery popper.js
    

    All I needed to do was to modify it from:

    @import "bootstrap";
    

    to

    @import 'bootstrap/scss/bootstrap';
    

    You can then add require the boostrap.js file in the app/javascript/packs/application.js file this way:

    require("bootstrap");
    

    That's all.

    I hope this helps

    0 讨论(0)
提交回复
热议问题