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?
Theoretically, npm-scripts provides the facilities to run scripts during
npm install
. You could for example add these lines to yourpackage.json
: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
and
All in all, I suggest that you instead focus your energy on adding proper installation instructions to your Readme.
If you have multiple gems you need for executing a ruby script in your node.js application, you can make a Gemfile and then add this preinstall/postinstall script to your package.json.