Installing ruby gems in a npm project

Mikael Lindqvist

I have a node.js project that depends on a ruby gem. Is it possible somehow to create an installation process that installs the gem dependencies in an easy way? Ideally, when I do

npm install

to install the npm dependencies, it would be great if the required ruby gems were installed as well.

Is there some kind of bridge between the two? If not, has anyone investigated this and found a suggested best practice or work around in these situations?

Patrick Oscity

Theoretically, npm-scripts provides the facilities to run scripts during npm install. You could for example add these lines to your package.json:

{ "scripts" :
  { "preinstall" : "/usr/bin/env gem install some_gem_name" }
}

Of course, you may want to add a more complex script that handles the case where Ruby and/or Rubygems are not installed, the Gem installation fails etc. etc. Installing dependencies can get arbitrarily complex, which is why many package developers (in any given language) often just assume that the required dependencies are already up and running on the target system. Finally, the npm-scripts documentation states that

INSTALL SCRIPTS ARE AN ANTIPATTERN

and

The only valid use of install or preinstall scripts is for compilation which must be done on the target architecture.

All in all, I suggest that you instead focus your energy on adding proper installation instructions to your Readme.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在npm项目中安装ruby gems

来自分类Dev

在npm项目中安装ruby gems

来自分类Dev

Ruby Gems无法运行

来自分类Dev

默认的Mac Ruby Gems?

来自分类Dev

Ruby gems 包安装失败

来自分类Dev

更新 Ruby Gems 时出错

来自分类Dev

安装Ruby Gems时遇到问题?

来自分类Dev

如何配置已安装的Ruby和gems?

来自分类Dev

如何完全删除Ruby + Rails + Gems?

来自分类Dev

如何从 Ruby 获取 gems 兼容版本

来自分类Dev

为什么在设置“ Ruby SDK and Gems”以使用Vagrant时在Rubymine中出现“错误复制Gems”

来自分类Dev

Error installing bcrypt with NPM in meteor

来自分类Dev

error in installing hiredis through npm

来自分类Dev

如何安装Ruby Gems,并一路缓存它们?

来自分类Dev

将“ PHP Composer”与“ Ruby Gems and Bundler”进行比较

来自分类Dev

是否有Ruby gems的版本管理器?

来自分类Dev

将Ruby bundler gems作为Xcode构建脚本运行

来自分类Dev

Ruby Gems C扩展示例不起作用

来自分类Dev

将Ruby bundler gems作为Xcode构建脚本运行

来自分类Dev

Ruby on rails Bundle 错误可能是由于 spree gems

来自分类Dev

使用其他 gems rails 调用 ruby 脚本

来自分类Dev

旧的 gems 总是适用于更高版本的 ruby 吗?

来自分类Dev

如何在Mac OS X 10.6.4上完全删除Ruby,Ruby gems

来自分类Dev

使用 Ruby gems 安装 Ruby-OAuth pkg 更独立于平台?

来自分类Dev

Heroku ruby buildpack错误-未定义的局部变量或方法`install_language_pack_gems'

来自分类Dev

使用Elastic Beanstalk在Amazon AWS上为非Rails ruby脚本安装Gems

来自分类Dev

为什么我的Ruby和Gems路径在使用Yeoman新版本时会导致错误?

来自分类Dev

Ruby gems安装错误openssl并安装了软件包

来自分类Dev

推荐的Ruby gems用于表单生成器和PDF生成器

Related 相关文章

热门标签

归档