Engine Yard Developer Center

Using 'yarn' to manage NodeJS modules for assets compilation

Engine Yard now supports the use of 'yarn' as an alternative to 'npm' for the installation of NodeJS modules. yarn has quickly become a major player on the Ruby world, fuelled by both its performance and its addition to Rails.

Since release 3.0.23 of our v5 stack, yarn is by default present on all instances, and initial support is present for utilising it to install the NodeJS modules needed for asset compilation.

To make use of yarn, please follow this process:

  • add a file named ey.yml to the config directory of your application and commit this to the repository. The file should contain the lines below. More information about what can be specified in the ey.yml file can be found here.
defaults:
  npm:  false
  • since yarn (or npm previously) is used to compile assets, add a before_compile_assets.rb deploy_hook with the code below. This code will be invoked by the deploy process before the assets are compiled, triggering yarn to install the NodeJS modules. Further informantion on using deploy_hooks can be found in the relevant KB article.
run! “cd #{config.release_path} && yarn"


And that's it. On a subsequent deploy, our backend will refrain from running npm when a package.json file is detected, and instead the deploy_hook will invoke yarn. When the assets_compilation stage triggers, the required NodeJS modules will be in place.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.

Powered by Zendesk