Ruby on Rails 基础(9)

2021-11-25 22:32:15 浏览数 (1)

报错:There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)

事实上我们系统里已经有了这个gem

代码语言:javascript复制
[root@h202 blog]# bundle list | grep uglifier
  * uglifier (3.0.0)
[root@h202 blog]# 

那为什么会报错呢,原因是 uglifier 这个包,其实是 JS 的一层包装,它需要 JS的运行环境或者JS的解释器

Uglifier minifies JavaScript files by wrapping UglifyJS to be accessible in Ruby

解决方法是安装 NodeJS

代码语言:javascript复制
[root@h202 blog]# yum install nodejs
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository base is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                | 3.8 kB     00:00     
 * base: mirrors.aliyun.com
 * epel: mirrors.opencas.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                         | 3.7 kB     00:00     
extras                                                                                                       | 3.4 kB     00:00     
percona-release-noarch                                                                                       | 2.5 kB     00:00     
percona-release-x86_64                                                                                       | 2.5 kB     00:00     
updates                                                                                                      | 3.4 kB     00:00     
zabbix                                                                                                       |  951 B     00:00     
zabbix-non-supported                                                                                         |  951 B     00:00     
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-4.el6 will be installed
--> Processing Dependency: libuv.so.0.10()(64bit) for package: nodejs-0.10.42-4.el6.x86_64
--> Running transaction check
---> Package libuv.x86_64 1:0.10.34-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
 Package                      Arch                         Version                                 Repository                  Size
====================================================================================================================================
Installing:
 nodejs                       x86_64                       0.10.42-4.el6                           epel                       2.1 M
Installing for dependencies:
 libuv                        x86_64                       1:0.10.34-1.el6                         epel                        57 k

Transaction Summary
====================================================================================================================================
Install       2 Package(s)

Total download size: 2.1 M
Installed size: 7.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): libuv-0.10.34-1.el6.x86_64.rpm                                                                        |  57 kB     00:00     
(2/2): nodejs-0.10.42-4.el6.x86_64.rpm                                                                       | 2.1 MB     00:13     
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                               147 kB/s | 2.1 MB     00:14     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
 Userid : EPEL (6) <epel@fedoraproject.org>
 Package: epel-release-6-8.noarch (@extras)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 1:libuv-0.10.34-1.el6.x86_64                                                                                     1/2 
  Installing : nodejs-0.10.42-4.el6.x86_64                                                                                      2/2 
  Verifying  : nodejs-0.10.42-4.el6.x86_64                                                                                      1/2 
  Verifying  : 1:libuv-0.10.34-1.el6.x86_64                                                                                     2/2 

Installed:
  nodejs.x86_64 0:0.10.42-4.el6                                                                                                     

Dependency Installed:
  libuv.x86_64 1:0.10.34-1.el6                                                                                                      

Complete!
[root@h202 blog]#

再次尝试 启动服务

代码语言:javascript复制
[root@h202 blog]# rails server
=> Booting WEBrick
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-04-22 13:28:17] INFO  WEBrick 1.3.1
[2016-04-22 13:28:17] INFO  ruby 2.3.0 (2015-12-25) [x86_64-linux]
[2016-04-22 13:28:17] INFO  WEBrick::HTTPServer#start: pid=11288 port=3000
...
...
...

0 人点赞