question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Javascript runtime required in production

See original GitHub issue

System configuration

Sprockets or Webpacker version: webpacker ^3.3.1 React-Rails version: 2.4.4 Rect_UJS version: ^2.4.4 Rails version: ~> 5.1 Ruby version: 2.4.1


Just added react-rails to our app and we are trying to compile the assets with docker for porduction We encounter this JavaScript runtime error when trying to start the server. But this error goes away if I add gem 'therubyracer' to my gem file. My question is do we absolutely need therubyracer gem even if we are not doing any server side rendering ?? Not sure if i miss it in the readme somewhere.

Dockerfile
From ...

WORKDIR /opt/app

RUN yum -y install git mysql-devel

COPY Gemfile Gemfile.lock package.json .npmrc yarn.lock /opt/app/
RUN bundle install --without development,test

COPY . /opt/app

# Remove anything added to build
RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && \
    curl -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && \
    yum install -y nodejs yarn && \
    yarn install && \
    bundle exec rake assets:precompile && \
    rm -rf node_modules && \
    yum autoremove -y nodejs && \
    yum -y clean all


Console


Message from application: There was an error while trying to load the gem 'react-rails'.
| Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
| Backtrace for gem load error is:
| /usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
| /usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
LS80commented, Apr 26, 2019
ENV EXECJS_RUNTIME=Disabled

Is probably what you want

2reactions
chulkileecommented, Sep 19, 2018

This is because react-rails always require execjs - see https://github.com/reactjs/react-rails/blob/v2.4.7/lib/react/jsx.rb#L1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails 4 - javascript runtime required in production
I just updated a Rails 3.2.x app to 4.0.2. When I deployed to production (ubuntu, MRI 2.0) I got the good old error...
Read more >
Rails 4 - javascript runtime required in production-ruby-on-rails
My capistrano tasks on production install bundle without :asset group, so after this change JS runtime is no longer required on production.
Read more >
Deno.js in production. Key takeaways. | by Steven de Salas
'Deno' ('No-de' flipped over) is a new JavaScript runtime announced in 2018 by the Node.js creator Ryan Dahl after commiserating his mistakes in...
Read more >
Build Time and Runtime - How Next.js Works
Build time (or build step) is the name given to a series of steps that prepare your application code for production. When you...
Read more >
Node.js Runtime Environment - App Engine - Google Cloud
To support Node.js packages that require native extensions, the runtime ... NODE_ENV (Only available in the Node.js runtime), Set to production when your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found