(React on Rails) The engine "node" is incompatible with this module. Expected version "..."

react-rails example
rails react scaffold
react-rails asset pipeline
react-rails-ujs
remove react rails
add react to existing rails app
why use react with rails
rails api with a separate frontend react app

For those familiar with the react-on-rails gem, or more generally, yarn:

Just today I updated my Node version to 8.8.1 via Homebrew. Now, when I attempt to run bundle && yarn && foreman start -f Procfile.dev (or just yarn install), I get the following message:

error react-webpack-rails-tutorial@0.0.1: The engine "node" is incompatible with this module. Expected version "5.10.0".

error Found incompatible module

info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

This is likely a very simple issue I am running into, but I have been unable to fix it after a few hours of debugging.

I tried manually updating my Node version in package.json to be that on my computer (did not seem to take effect whatsoever), downgrading my version to 5.10.0 via Homebrew (but was unable to), and even upgrading to the latest version of the gem which meant installing webpack as well.

No matter what I did, my local server startup (bundle && yarn && foreman start -f Procfile.dev) still lead to the same error above. Any ideas for this poor soul?

For anyone running into this same issue, I have not found a solution for the underlying issue but I have found a temporary workaround.

Simply run

bundle && yarn --ignore-engines && foreman start -f Procfile.dev

instead of

bundle && yarn && foreman start -f Procfile.dev

I hope this helps someone else that may have found themselves stuck in the same situation!

Integrate React.js with Rails views and controllers, the asset pipeline, or webpacker. - reactjs/react-rails. Place gem 'react_on_rails', '~> 6' before the gem pointing at your engine in your gemfile. This is necessary because React on Rails attaches itself to the rake assets:precompile task. It then uses a direct path to cd into client, which will not exist in the main app that includes your engine.

You need to update your Node.js version. Try to

  1. Clear NPM's cache:

sudo npm cache clean -f

  1. Install a little helper called 'n'

sudo npm install -g n

  1. Install latest stable Node.js version

sudo n stable

The lack of documentation and blog posts on this topic is painful. I would have imagined it to be a more popular request. For anyone else  By using React to render components from within a Rails view instead of the Rails template engine, your application will benefit from the latest advancements in JavaScript and front-end development while still leveraging the expressiveness of Ruby on Rails.

I give you this list of checks to do from the react-webpack-rails-tutorial github page

Basic Demo Setup
  1. Be sure that you have Node installed! We suggest nvm, with node version v6.0 or above. See this article Updating and using nvm.

  2. git clone git@github.com:shakacode/react-webpack-rails-tutorial.git cd react-webpack-rails-tutorial

  3. Check that you have Ruby 2.3.0 or greater
  4. Check that you're using the right version of node. Run nvm list to check. Use 5.5 or greater.
  5. Check that you have Postgres installed. Run which postgres to check. Use 9.4 or greater.
  6. Check that you have qmake installed. Run which qmake to check. If missing, follow these instructions: Installing Qt and compiling capybara-webkit
  7. Check that you have Redis installed. Run which redis-server to check. If missing, install with Homebrew (brew install redis) or follow these instructions.
  8. bundle install
  9. brew install yarn
  10. yarn
  11. rake db:setup
  12. foreman start -f Procfile.hot
  13. Open a browser tab to http://localhost:3000 for the Rails app example with HOT RELOADING
  14. Try Hot Reloading steps below!
  15. foreman start -f Procfile.static
  16. Open a browser tab to http://localhost:3000 for the Rails app example.
  17. When you make changes, you have to refresh the browser page.

Given that rails/webpacker gem already provides basic React integration, why would you use "React on Rails"? +. Server rendering, often used  Similar to the react-rails gem, now that Rails already provides an easy way to use React via webpacker, you have to see if the stated benefits of the react_on_rails gem apply to your situation. The main benefits include better support for server side rendering, easy passing of props to React components (with the react_component method just like

By using React to render components from within a Rails view instead of the Rails template engine, your application will benefit from the latest  Hi all, Thanks for the great Gem. Have absolutely loved using this with my Rails app! Just today I updated my Node version to 8.8.1 via Homebrew. Now, when I attempt to run bundle && yarn && foreman start -f Procfile.dev (or just yarn in

I am having issues with using react on rails gem in a rails engine as the front end of the rails app. According to the documentation, I have done  Place gem 'react_on_rails', '~> 6' before the gem pointing at your engine in your gemfile. This is necessary because React on Rails attaches itself to the rake assets:precompile task. It then uses a direct path to cd into client, which will not exist in the main app that includes your engine.

Some of the features of using react-rails gem are: It automatically Most of the search engine robots do not execute client side javascript code. React on Rails integrates Rails with (server rendering of) Facebook's React front-end framework. This project is sponsored by the software consulting firm ShakaCode . We focus on React front-ends, often with Ruby on Rails or Gatsby.

Comments
  • Hey Fabrizio, appreciate the suggestion. Unfortunately this issue was encountered far after the tutorial and initial install. It appeared to only arise after upgrading node versions via Homebrew!