# Ruby gems with npm packages

**URL:** <https://metaruby.com/t/ruby-gems-with-npm-packages/1063>\
**Category:** Ruby Chat\
**Tags:** ruby, javascript\
**Created:** [June 4, 2017, 3:51pm UTC](https://metaruby.com/t/ruby-gems-with-npm-packages/1063 "2017-06-04T15:51:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glebm](https://metaruby.com/user_avatar/metaruby.com/glebm/32/976_2.png) [@glebm](https://metaruby.com/u/glebm)\
**Post date:** [June 4, 2017, 3:51pm UTC](https://metaruby.com/t/ruby-gems-with-npm-packages/1063/1 "2017-06-04T15:51:47Z")

</div>

I have figured out a robust way to have ruby gems depend on npm packages.  
Ruby will install the npm dependencies during gem installation (using an `extconf.rb` trick), and fail to install if npm installation fails for whatever reason.

Example: [GitHub - glebm/critical-rubygem: The `critical` npm package wrapped as a Ruby gem](https://github.com/glebm/critical-rubygem) - a Ruby wrapper for the [critical](https://github.com/addyosmani/critical) npm package.
