Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install PhantomJS in GitLab CI by selecting a Node image with a working shell, installing Linux Fontconfig, running npm ci from a committed lockfile, and invoking ./node_modules/.bin/phantomjs from your job script. The npm package downloads a platform-specific binary, so network access, PATH, permissions and runner architecture determine whether installation succeeds. PhantomJS is a legacy choice: GitLab reported switching its own tests to headless Chrome in 2017, so use this setup when an existing suite still depends on PhantomJS and evaluate a modern browser runner for new work.

What the GitLab CI job needs

A GitLab job runs its script commands inside the image selected by image. With the Docker executor, that image is an isolated container, so it must contain a usable shell and the tools your commands call.

  • A pinned Node-based image, such as node:20-bookworm.
  • Your project’s package.json and committed package-lock.json.
  • The phantomjs npm package as a development dependency.
  • Fontconfig in Linux images. The PhantomJS package notes that Qt and WebKit do not need separate installation, but Fontconfig is still required.
  • Runner network access to download the package’s prebuilt binary, unless you provide an approved mirror or a PhantomJS executable on PATH.

Prepare a minimal PhantomJS project

Install and lock the dependency

Run this locally with the Node and npm versions used by your project:

npm install --save-dev phantomjs

Commit both package.json and package-lock.json. The lockfile records the dependency tree that CI should reproduce; do not rely on a fresh, uncommitted install.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Create a small page runner

This example opens a URL supplied as the first argument and returns a nonzero exit code when the page cannot be opened. Replace it with your existing test harness if you already have one.

var system = require('system');
var page = require('webpage').create();
var url = system.args[1] || 'https://example.com';

page.open(url, function (status) {
  if (status !== 'success') {
    console.error('Unable to open ' + url + ': ' + status);
    phantom.exit(1);
    return;
  }

  console.log('Opened ' + url);
  phantom.exit(0);
});

Save it as test/runner.js. Calling the binary through ./node_modules/.bin/phantomjs ensures the job uses the version installed for this project rather than an unrelated system executable.

Use a reproducible .gitlab-ci.yml

The following job follows the legacy pattern: install Fontconfig, perform a clean lockfile install, then invoke PhantomJS from the project.

image: node:20-bookworm

stages:
  - test

phantomjs_test:
  stage: test
  before_script:
    - apt-get update
    - apt-get install -y --no-install-recommends fontconfig
    - rm -rf /var/lib/apt/lists/*
    - npm ci
  script:
    - ./node_modules/.bin/phantomjs test/runner.js https://example.com

If your organization maintains a custom image, install Fontconfig in that image instead of running apt-get on every job. The important properties are the same: a working shell, Node, the archive tool used by the installer, Fontconfig, and a writable npm installation and cache location.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why npm ci belongs in CI

npm documents npm ci as a clean lockfile installation. It removes the existing dependency directory and installs the versions recorded in the lockfile, failing rather than silently rewriting it. If you created the lockfile with options that change dependency-tree shape, such as a peer-dependency mode, use the same options in CI. A mismatch can make a locally successful install fail in the runner.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

How the PhantomJS npm installer finds its binary

Platform and architecture detection

The npm package downloads a prebuilt PhantomJS binary for the detected operating system. When the runner’s platform or architecture is unusual, set PHANTOMJS_PLATFORM and PHANTOMJS_ARCH explicitly. You can also place an approved PhantomJS binary on PATH; the package can use that executable instead of downloading one.

Linux Fontconfig

Fontconfig is a runtime requirement on Linux. A job can complete npm ci and still fail when PhantomJS starts if the image lacks it. Install the package in the image, or choose an image that already includes it, before invoking the test.

Download mirrors and proxies

Binary download failures usually indicate a network path problem rather than a test failure. Configure an approved internal mirror, or supply a binary on PATH, when outbound downloads are restricted. Do not make strict-ssl=false a routine workaround: the package documentation describes it as risky for intercepting proxies. Install and trust the proxy’s certificate chain or use the approved mirror instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make cross-platform runs predictable

Native binaries are platform-specific. If dependencies were produced on a different operating system or architecture, run npm rebuild in the target environment as described by the package documentation, then regenerate and commit the lockfile only when the dependency graph actually changes. The safest normal path is to create the lockfile with the same family of Node image used in CI and let npm ci install it without modification.

Troubleshoot installation and startup failures

spawn ENOENT

This means the process launcher cannot find a required executable. Check that both node and tar are on PATH inside the selected image. Confirm the job is calling ./node_modules/.bin/phantomjs after npm ci, not a path that exists only on your workstation.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Permission denied while installing

The CI user must be able to write the npm cache, the project directory and the dependency installation directory. Use an image and runner user with matching ownership, or point npm’s cache at a writable location. Avoid changing permissions broadly across the container when fixing one directory.

ECONNRESET or ETIMEDOUT during npm ci

The installer could not download the PhantomJS binary. Verify DNS, proxy and firewall rules from the runner, then use an approved mirror or put a compatible binary on PATH. Retrying the same job without fixing the network path is not a reproducibility strategy.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PhantomJS starts and immediately fails on Linux

Install Fontconfig and rerun the job. If it is already present, check that the package is available to the same user and image layer that runs the test.

Dependencies work locally but not in CI

Check for a lockfile generated on another platform, architecture or npm configuration. Run npm rebuild in the CI environment when required by the package documentation, and ensure CI uses the dependency-tree flags used to create the lockfile.

The job fails before script starts

The selected image may not provide a working shell, or the runner may not support the image’s execution model. GitLab’s Docker executor expects an image in which it can run the job shell. Test the image with a trivial job that prints the Node and npm versions before adding PhantomJS.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Operational and security considerations

Keep the legacy surface isolated

Put PhantomJS jobs in their own stage or job so a future migration can replace the runner without changing unrelated pipelines. Pass the target URL or test selection as a variable rather than editing the script for every environment, and keep secrets out of command-line output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Expect network-dependent setup

Unless the binary is already on PATH or available through an approved mirror, each clean installation depends on the package download completing. Record the image, Node version, npm configuration and lockfile revision with the pipeline so a failed run can be reproduced.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

PhantomJS versus a modern browser runner

GitLab wrote in 2017 that it had switched from PhantomJS to headless Chrome for frontend and RSpec feature tests. The same report said PhantomJS had been part of GitLab’s test framework for “almost five years” at that time. Those statements are historical context, not a current GitLab support guarantee.

Before investing in more PhantomJS-specific CI work, compare the legacy suite and a modern runner on these axes:

Decision axis Questions to answer
JavaScript and web-platform compatibility Does the browser implement the APIs and rendering behavior used by the application?
Binary and image availability Can the required browser be installed reliably for the runner’s operating system and architecture?
Diagnostics Will failures provide useful logs, screenshots, console output and network information?
Startup and reproducibility Can the team pin the image and dependencies without relying on an unreliable download?
Migration effort How much page script, selector logic and assertion code must be rewritten?

If compatibility, diagnostics or binary availability are already limiting PhantomJS, treat the job above as a containment setup while you plan migration rather than as a new long-term standard.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Runbook checklist

  1. Pin the Node image used by the job.
  2. Commit package.json and package-lock.json.
  3. Install Fontconfig in the Linux image.
  4. Verify Node and tar are on PATH.
  5. Run npm ci with the same dependency-tree options used to create the lockfile.
  6. Invoke ./node_modules/.bin/phantomjs from the job.
  7. For restricted networks, configure an approved mirror or provide a binary on PATH.
  8. For cross-platform dependency artifacts, run npm rebuild in the target environment.
  9. Keep TLS verification enabled unless your security team has documented a trusted certificate solution.

Or skip the browser setup

If your goal is to capture a rendered page rather than execute PhantomJS assertions, ScreenshotNeo provides a website screenshot API and MCP server. One request returns a PNG, JPEG, WebP or PDF. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Use the ScreenshotNeo API documentation for authentication and options. The following calls are runnable examples.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const buffer = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('shot.webp', buffer);

ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, clicks before capture, selector waits, delays or network-idle waits, request and resource blocking, custom headers, cookies, user agents, Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. Common parameter names used by other screenshot APIs also work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is a free allowance of 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan. Sign up free for ScreenshotNeo and test the capture you need before changing your CI browser.

Frequently Asked Questions

Can ScreenshotNeo run my PhantomJS test scripts?

No. ScreenshotNeo is a screenshot, page-information and PDF service; keep PhantomJS or another browser runner for DOM assertions and scripted tests.

Is the GitLab migration to headless Chrome a current compatibility promise?

No. GitLab’s statement was published in 2017 and should be treated as historical context, not a guarantee about today’s runners or support policies.

What should I preserve when moving this job to another runner architecture?

Preserve the lockfile, verify the target image has Node, tar, a shell and Fontconfig, and rebuild dependencies in the target environment when they were created on a different platform.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.