Ruby on Rails - Not importing SCSS

2019-07-20 07:04发布

问题:

I'm making a new RoR application while trying to use the bootstrap gem but I've ran into some problems when running it for the first time. Looks like Ruby is having a hard time including the scss file

ExecJS::ProgramError in Visitor#index
Showing */app/views/layouts/guest.erb where line #8 raised:

identifier '(function(opts, pluginOpts) {return eval(process' undefined

Guest.erb

<!DOCTYPE html>
<html>
<head>
  <title>FooBar</title>
  <%= csrf_meta_tags %>
  <%= csp_meta_tag %>

  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
</head>

<body>
<%= yield %>
</body>
</html>

application.scss

 * ...........
 * It is generally better to create a new file per style scope.
 *
 */
@import "bootstrap";

Gem File

ruby '2.4.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
#Bootstrap
gem 'bootstrap', '~> 4.1.1'

回答1:

Remove duktape gem from your Gemfile and make sure Node.js is installed or something. There should be a comment for alternatives pointing to https://github.com/rails/execjs#readme .



回答2:

The message, "identifier '(function(opts, pluginOpts) {return eval(process' undefined" looks like a JavaScript issue. That text matches code found here in this Rails Autoprefixer. Unfortunately, I don't know a quick fix to suggest, but since the options for that function takes file names, I'd double check to make sure there are no typos in the stylesheet file names anywhere (ie., the files themselves and wherever they might be referenced).

share|improve this answer

Your Answer

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged ruby-on-rails ruby bootstrap-4 or ask your own question.

收藏的人(0)

Ta的文章 更多文章
登录 后发表评论
0条评论
还没有人评论过~