本文介绍了Ruby on Rails-不导入SCSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用bootstrap gem时,我正在制作一个新的RoR应用程序,但是第一次运行它时遇到了一些问题.看起来Ruby很难包含scss文件

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>

应用程序. scss

application.scss

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

宝石文件

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'

推荐答案

从Gemfile中删除 duktape gem,并确保已安装Node.js或其他内容.对于指向 https://github.com/rails/execjs#readme.

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 .

这篇关于Ruby on Rails-不导入SCSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!