Gitlab CI setup error - Could not find a JavaScript runtime

Gitlab-CI can be configured with the file .gitlab-ci.yml in this case:

before_script:
- apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs

can be used to install nodejs on the setup stage (source).

A complete before_script with jekyll can look like the following code (for instance, this is required for jekyll-minifier):

image: ruby:latest

variables:
  JEKYLL_ENV: production
  LC_ALL: C.UTF-8

before_script:
  - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
  - ruby -v
  - which ruby
  - gem install bundler
  - bundle install

test:
  stage: test
  script:
  - bundle exec jekyll build -d test
  artifacts:
    paths:
    - test
  except:
  - master

pages:
  stage: deploy
  script:
  - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master


You need to have a javascript runtime (e.g. nodejs). You can install it by using the following command:

For Ubuntu Users

sudo apt-get install nodejs

For CentOS / RedHat Users

sudo yum install nodejs

In case you can't install nodejs you can install and then use therubyracer gem.

Description from repository:

Embed the V8 JavaScript interpreter into Ruby.

Add this line to your Gemfile

gem 'therubyracer', platforms: :ruby