An official example does not guarantee the same result everywhere
You find an example in the Node.js documentation, add it to the application, and run it successfully on your laptop. CI—continuous integration, which automatically builds and tests changes—then produces a red build. Alternatively, every automated check passes, but deployment fails because a function or module does not exist.
This is not necessarily a coding mistake or a sign that someone ignored the instructions. Your browser may show documentation for one Node.js version, your laptop may have another installed, and the container or production server may execute a third.
Do not begin by rewriting the example. Start with the simplest available check:
node --version
node -p 'process.execPath'
The first command reports the runtime version. The second helps identify the exact Node.js executable selected by the current shell.
Three facts that are easy to mix up
On July 24, 2026, the Node.js project announced a beta version of its new API documentation. This was a documentation preview announcement, not a Node.js runtime release, so it does not update an application’s installation by itself.
An API, or application programming interface, is a set of functions, classes, and other capabilities that a program can use. Keep three separate facts in view:
- Which documentation interface is open in the browser.
- Which Node.js version the page describes and what status it gives the required API.
- Which Node.js version actually executes the code.
A beta label on the documentation interface does not by itself determine the status of a particular API. Likewise, a new documentation interface cannot make a newer API available in an older runtime.
Version-specific documentation states the claimed support. A small test confirms only that the tested operation worked with a particular Node.js executable in a particular scenario. A reliable conclusion requires both checks.
Build a map of actual versions
In the main scenario, the example works on a laptop but fails in CI. Record actual values rather than expected ones. PATH is the list of directories in which the shell searches for executables, including node.
| Environment | Actual version | Where it comes from | Test result |
|---|---|---|---|
| Laptop | [output] | version-selection tool or PATH | [result] |
| CI | [output] | job configuration | [result] |
| Container image | [output] | built image | [result] |
| Production | [output] | deployed artifact | [result] |
Temporarily print node --version before the CI tests. If the container image permits an alternate command, inspect the same image you intend to deploy:
docker run --rm <image> node --version
If the image’s custom startup configuration intercepts the arguments and the command does not run, use the team’s approved diagnostic method for that image. Do not infer the Node.js version merely from the command’s failure.
Next, inspect .nvmrc, .node-version, the engines field in package.json, the Node.js setup step in CI, and the FROM line in the Dockerfile. In a multistage Dockerfile, the relevant stage is the one that produces the final image, not necessarily the first FROM line.
The engines field declares an intended version range. Depending on configuration, tooling may warn or reject an installation, but the field itself neither installs Node.js nor proves which version is currently executing the code. An image tag also does not prove that production already runs the build you inspected.
If direct server access is restricted, collect process.version through an approved application diagnostic or startup log. A command in an interactive shell may resolve to a different executable from the one used by the service process.
Match the documentation to the runtime
A search result may lead to current documentation even when the project supports an older Node.js release. Check the version shown on the page and in its URL when available. Then open documentation for every version the team actually runs.
If environments differ intentionally, the oldest supported runtime is the baseline for a code path that must execute in all of them. A newer API can be used where the runtime has been upgraded in a coordinated way or behind a separate, tested compatibility path. Do not replace this check with the assumption that an official example must work in every supported release.
When an official version-specific URL is available, save it in the code review or team guide. If the link does not preserve the version unambiguously, write the tested Node.js version next to it.
Confirm the API with a smoke test
The following template checks only whether a module export exists. It is not a universal test for a global API, an object method, or particular behavior. Replace the placeholders:
const moduleName = 'node:MODULE_NAME';
const exportName = 'EXPORT_NAME';
const mod = await import(moduleName);
if (!(exportName in mod)) {
throw new Error(`Missing ${exportName} in ${moduleName} on ${process.version}`);
}
console.log(`Available on ${process.version}`);
Run the file with the runtime being investigated:
node check-api.mjs
docker run --rm -v "$PWD:/work" -w /work <image> node check-api.mjs
The second command runs the local test file with Node.js from the selected image, provided the image configuration permits that command. It does not prove that production already has that image deployed.
For a global API, inspect the relevant property on the global globalThis object. For a method, inspect the object that is expected to provide it. A missing named export in this template does not prove that the API is absent when the documentation specifies another access pattern.
The presence of an export also does not guarantee the required behavior. If the application depends on a particular option or result, add the smallest safe call and an explicit assertion of the expected result.
Do not experiment directly on a production server. First run the check in CI or a test environment with the same container image intended for deployment. If the API is critical, keep the relevant smoke test in CI. A later change to Node.js, the image, or the CI configuration can then produce a focused failure before deployment.
Anti-patterns that hide the mismatch
- Linking only to the documentation home page without version context.
- Treating
latestas a reliable way to reproduce an environment. - Testing the API only on the change author’s laptop.
- Reading
enginesinpackage.jsonas proof of the installed version. - Confusing the beta status of the documentation interface with the status of an API.
- Upgrading production only because an example failed, without checking the effects of that upgrade.
- Running an unreviewed compatibility experiment directly in production.
Audit links used by the team
After fixing the build, review the wiki, architecture decision records, incident instructions, and onboarding material. Beside every version-sensitive example, state the supported Node.js range and link to the matching documentation. If a stable version-specific link is unavailable, record the version in plain text next to the link.
The team can adopt the new documentation interface after a practical check: the relevant version is easy to identify, important APIs can be found, saved links lead to the expected content, and the team has an agreed fallback route during the transition. Adopting a new interface should not silently change the application’s Node.js support policy.
The central rule is simple. A browser page is a source of information, but the runtime determines the actual result. A recorded version map, version-specific documentation, and a small targeted test turn a surprise failure into a routine check.
Sources
Quick checklist
- run `node --version` in every environment
- match the documentation page to the actual Node.js version
- verify the required API with a smoke test
- run the test in the same container image as the application
- review version-sensitive links in team documentation
Check Node.js API compatibility across environments
Help me verify whether a selected Node.js API is supported in every project environment. Inputs: - API, module, or global object name; - documentation URL and the Node.js version described by that page; - node --version output from the laptop, CI, container image, and production environment; - version-management files, CI configuration, and the FROM line from the Dockerfile; - error message or unexpected behavior; - environments and Node.js versions the team officially supports. Do not assume that latest or the package.json engines field identifies the installed version. List missing evidence separately. Return Markdown with these sections: 1. Short conclusion. 2. Table of environments and actual versions. 3. Most likely source of the mismatch. 4. Exact verification commands. 5. Minimal API test. 6. CI check. 7. Links and instructions that should be updated. 8. Unknowns and the safest next step.