skip to content

When the Gatling JavaScript CLI runs a TypeScript simulation, what is it executing the simulation on, and what does that rule out when you add an npm library to the project?

level: seniorimportance: should knowfreq 25%

answer

  1. npm ships the code, not the engine
  2. A separate runtime bundle is downloaded
  3. It caches in a home-directory .gatling folder
  4. No native binaries, no Node-only APIs

basics

~20 s

Not your local Node process. The gatling CLI downloads a Gatling runtime bundle and caches it under a .gatling home directory, and runs your simulation there — so added libraries must avoid native binaries and Node-specific JavaScript APIs.

solid answer

~40 s

npm and Node install your dependencies and give you the `gatling` command, but they are not what executes the load test. The CLI downloads a **Gatling runtime bundle** from Gatling's releases and installs it under `~/.gatling` (or `%USERPROFILE%\.gatling` on Windows), relocatable with `--gatling-home`, and your simulation runs there. That is why the documented rule for extra npm dependencies is two-part: a library must not rely on **native, non-JavaScript binaries**, and must not use **JavaScript APIs specific to Node.js**. Dev dependencies are unaffected, because a formatter or linter only ever runs over your source. The practical consequences are operational: the first run needs network access, the CLI inherits npm's proxy settings, and an isolated machine needs the bundle installed by hand with `npx gatling install`.

code

bash · 3 lines
bash
export HTTPS_PROXY="http://proxy.example.com:3128"
npx gatling install "./gatling-js-bundle.zip"
npx gatling run --gatling-home "/opt/gatling-home" --simulation "checkout"

go deeper

for a junior

Be ready to say that the gatling command downloads something the first time it runs, and that not every npm library is usable inside a simulation.

for a middle

Explain the split: npm installs the authoring packages and the CLI, while a separately downloaded runtime bundle executes the simulation, which is what the two dependency rules follow from.

for a senior

Own the operational cases — proxies inherited from npm, a hand-installed bundle on an isolated machine, a relocated gatling home — and screen dependencies against the rules before adopting them.

for a principal

Decide how the runtime bundle is provisioned across an organisation, and what a team is allowed to depend on inside simulation code, before dozens of repositories bake the answer in.

It is easy to read `npm install`, `npx gatling run` and a `.ts` file and conclude that a Gatling JavaScript simulation is a Node program. It is not, and almost every operational surprise in this SDK follows from that one fact. ## What npm actually does here npm plays three roles, none of which is *running the test*: - it **resolves and installs** `@gatling.io/core`, `@gatling.io/http` and any protocol packages, so your source has something to import; - it **installs the CLI** as a dev dependency, so `npx gatling` resolves an executable inside the project; - it **installs your own toolchain** — formatters, linters, type-checking — which run over your source and nothing else. A hint of what lies underneath is visible in the dependency graph itself: `@gatling.io/core` and `@gatling.io/http` both pull a shared package called `@gatling.io/jvm-types`. The npm packages are the authoring surface; they are not the load generator. ## Where the engine comes from The `gatling` CLI needs internet access to **automatically download the Gatling runtime bundle required to execute your simulations**, published on Gatling's `gatling-js` releases. By default it installs into: | platform | default location | override | |---|---|---| | Linux / macOS | `~/.gatling` | `--gatling-home` | | Windows | `%USERPROFILE%\.gatling` | `--gatling-home` | Because that directory is **outside your project**, it is shared across every Gatling JavaScript project on the machine and survives deleting `node_modules`. It also has to match the SDK version in `package.json`, which is another reason the `@gatling.io` packages move as one. ## The two dependency rules, and what they follow from You may add other npm libraries to a simulation project, **as long as**: 1. they do **not rely on native (non-JavaScript) binaries**; and 2. they do **not use JavaScript APIs which are specific to Node.js**. Both rules say the same thing from two directions: your simulation code is evaluated by the Gatling runtime bundle, not by the Node process that launched the CLI. A library that shells out to a compiled addon has nothing to bind to, and one that reaches for Node's own APIs is assuming a host that is not there. Pure-JavaScript utilities — date formatting, string generation, data shaping — are the safe shape. Dev dependencies are outside this entirely. Gatling's demo projects ship a Prettier configuration precisely because formatting your source never runs inside the load test. ## Working on a restricted machine The download is the part that surprises people on locked-down networks. Three facts cover almost every case: 1. **Proxies are inherited from npm.** The CLI picks up npm's proxy configuration when run through `npx gatling`, whether that comes from `HTTP_PROXY` / `HTTPS_PROXY` / `NOPROXY` or from a `.npmrc` — there is no separate Gatling proxy setting to configure. 2. **The bundle can be installed by hand.** Download the release archive matching the version pinned in `package.json` **and** your machine's system type and architecture, then run `npx gatling install <path-to-downloaded-file.zip>`. 3. **The cache can be relocated.** `--gatling-home` moves it, which matters when the home directory is small, shared, or wiped between sessions. ## What this changes about how you think about the SDK - **"It works on my laptop" has a new failure mode**: a machine that has already cached a bundle behaves differently from one that has not, and the difference is a network call, not your code. - **Library choice is a design constraint, not a preference.** Screen a candidate dependency against the two rules before you build test data tooling on top of it, because discovering the constraint after the helper library is embedded is expensive. - **Version drift is now two-sided**: the npm packages and the downloaded runtime both carry a version, and the documented upgrade procedure — bump `core`, `http` and `cli` together, reinstall — is what keeps them aligned. - **A dependency review is worth doing once, up front.** Transitive dependencies count as much as direct ones, so a small, apparently pure helper that pulls in a native module is the case that catches teams out — screen the tree, not just the package you chose. Note the boundary of what any of this tells you: it describes what the tooling installs and what the documentation permits. Precisely how the runtime evaluates a given library at run time is not something the packaging documentation states, so treat the two dependency rules as the contract and verify a borderline library by trying it rather than by reasoning about internals.

  • How do you run the Gatling JavaScript CLI on a machine with no internet access?
    Download the runtime bundle from Gatling's releases page by hand, matching both the version pinned in `package.json` and the machine's system type and architecture, then install it with `npx gatling install <path-to-file.zip>`. `--gatling-home` moves where it is installed if the default home directory is unsuitable.
  • Does the CLI need its own proxy configuration?
    No. Run through `npx gatling`, it inherits npm's proxy settings, so configuring `HTTP_PROXY`, `HTTPS_PROXY` and `NOPROXY`, or the equivalent keys in `.npmrc`, is enough. Looking for a Gatling-specific proxy setting is a common dead end.
  • Is a pure-JavaScript utility library safe to add to a simulation project?
    It is the shape the documented rules allow: no native binaries and no Node-specific APIs. Screen the dependency against both rules before building on it, and remember that transitive dependencies count — a small pure library that pulls a native one is the case that catches teams out.

The npm packages are a typed remote control and the CLI is the courier that fetches the box it points at. Buying a fancier remote — a library that only makes sense to Node — does not add a button the box has.

saying these in an interview costs you the question

  • Assuming simulations execute on the local Node.js runtime
  • Adding a library with native bindings to simulation code
  • Expecting a first run to work with no network access
  • Hunting for a Gatling proxy setting separate from npm's