Skip to content

Javascript runtime required in production #886

Closed
@AirWick219

Description

@AirWick219

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>'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions