我是Middleman和Ruby的新手。我先安装了rvm:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
\curl -L https://get.rvm.io | bash -s stable --ruby
我在PATH中添加了〜/ .rvm / bin,然后用rvm安装了Ruby:
rvm install ruby
rvm --default use ruby-2.2.1
然后我安装了Middleman并创建了一个新项目:
gem install middleman
cd ~/Documents/Web
middleman new my_project
cd my_project
我安装了midman-bower:
gem install middleman-bower
我在Gemfile中添加了:
gem 'middleman-bower'
并在config.rb中:
activate :bower
sprockets.append_path File.join "#{root}", "bower_components"
然后运行:
bundle install
尝试用以下方法进行测试:
middleman build
然后我收到以下错误:
/home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/extensions.rb:68:in `register': You must provide a Middleman::Extension or a block that returns a Middleman::Extension (RuntimeError)
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:21:in `<module:Bower>'
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:5:in `<module:Middleman>'
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:4:in `<top (required)>'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:85:in `require'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:85:in `rescue in block in require'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:68:in `block in require'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `each'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `require'
from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler.rb:134:in `require'
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/load_paths.rb:33:in `setup_bundler'
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/load_paths.rb:15:in `setup_load_paths'
from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-cli-4.1.1/bin/middleman:10:in `<top (required)>'
from /home/alain/.rvm/gems/ruby-2.2.1/bin/middleman:23:in `load'
from /home/alain/.rvm/gems/ruby-2.2.1/bin/middleman:23:in `<main>'
from /home/alain/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /home/alain/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
谷歌没有任何帮助。有什么奇怪的是没有凉亭可执行文件。我当时试过了:
gem install bower
但即使我评论了config.rb的最后几行,它也没有任何改变:
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
configure :development do
activate :livereload
end
# add bower support
activate :bower
sprockets.append_path File.join "#{root}", "bower_components"
请问好吗?
编辑:如果我删除rvm文件夹和中间人项目,并重做除 bower 之外的所有内容,一切都会好的。所以我的问题看起来如何正确安装凉亭
编辑:我应该说这也是我的第一个node.js设置!以下功能可以使用节点安装程序安装bower:apt-get install npm
npm install -g bower
但问题仍然存在!
我也试过this wrapping solution,但仍然没有进展:
after_configuration do
sprockets.append_path File.join root.to_s, "bower_components"
end
答案 0 :(得分:0)
我遇到了同样的问题,但我使用的是中间人v4,它不支持链轮。 我通过阅读:https://github.com/middleman/middleman/issues/890
找到了这一点在中间人网站上,他们还提到(https://middlemanapp.com/basics/upgrade-v4/#external-tools)他们删除了链轮。
首先我在Gemfile中添加了这个sprockets gem版本:
gem "middleman-sprockets", "~> 4.0.0.rc"
然后我在config.rb文件中添加了这行代码。
import_path File.expand_path('bower_components', app.root)
最后我跑到终端:
bundle install
它从那里起了作用。
还应该提到我没有使用&#34; midman-bower&#34;宝石就像你一样,我手动安装了凉亭。
希望这有帮助