在 npm 项目中安装 ruby​​ gems [英] Installing ruby gems in a npm project

查看:70
本文介绍了在 npm 项目中安装 ruby​​ gems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖 ruby​​ gem 的 node.js 项目.是否有可能以某种方式创建一个以简单方式安装 gem 依赖项的安装过程?理想情况下,当我这样做时

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

要安装 npm 依赖项,如果还安装了所需的 ruby​​ gem,那就太好了.

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?

推荐答案

理论上,npm-scripts 提供了在 npm install 期间运行脚本的工具.例如,您可以将这些行添加到您的 package.json:

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" }
}

当然,您可能想要添加一个更复杂的脚本来处理未安装 Ruby 和/或 Rubygems、Gem 安装失败等情况.安装依赖项可以变得任意复杂,这就是许多软件包开发人员的原因(在任何给定的语言中)通常只是假设所需的依赖项已经在目标系统上启动并运行.最后,npm-scripts 文档指出

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

安装脚本是一种反模式

安装或预安装脚本的唯一有效用途是编译,必须在目标架构上完成.

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.

这篇关于在 npm 项目中安装 ruby​​ gems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆