Commit Graph

20 Commits

Author SHA1 Message Date
Matt Godbolt (bot acct)
eee2e8bfd9 Improve node discovery: version-manager aware, single source of truth (#8845)
## What

Reworks the bespoke `etc/scripts/find-node` and its `Makefile`
interaction so node discovery works out of the box on Linux and macOS,
is optionally friendly to version managers, and stays sympathetic to
people who just use system node.

### Before
- Only ever looked at `PATH`, plus a vestigial
`/opt/compiler-explorer/node` hardcode (an affordance for one dev's
local setup, unused by the live site).
- Duplicated the required node version in three places (`find-node` had
`22` twice; `.node-version`; `package.json` `engines`).
- Silently fell back *past* an unusable `NODE_DIR` to whatever else it
found.
- nvm users got whatever default was active, not the version this repo
pins.
- Nagged on any version that wasn't exactly `22.x`, even newer ones.

### After — clear, permissive resolution order
1. **`$NODE_DIR/bin/node`** — explicit override, now authoritative. If
it's set but missing/too old you get a clear error instead of a silent
fallback.
2. **`node`/`nodejs` on `PATH`** — covers system node *and* any version
manager with shell integration (fnm, asdf, nodenv, volta, an active
nvm). Zero extra steps on a well-configured machine.
3. **Manager rescue** — only when PATH node is absent or below the
minimum: source `nvm` and ask for the pinned version (the one manager
that's a shell function rather than a PATH binary), then try
`fnm`/`nodenv`/`asdf`. Each branch is inert unless that tool is
installed, so nobody is pushed onto a manager.

Other changes:
- **Single source of truth**: the minimum major now comes solely from
`.node-version` (the same file the managers read). Newer majors are
always fine — the "only tested against v22.x" warning is dropped.
- **`Makefile`**: `.node-bin` now also depends on `.node-version`, so
bumping the pin re-resolves node instead of serving a stale cache. The
lazy-dotfile pattern (so failures abort `make` and `make help` pays
nothing) is kept.
- **`README`**: documents the PATH-first + manager-rescue behaviour.

## Testing
- `shellcheck` clean.
- Verified: PATH discovery, valid/bogus `NODE_DIR`, nvm rescue (shadowed
`node`+`nodejs` with v18 shims → skipped them and resolved v22.22 via
nvm), too-old fallthrough, no-node/no-manager failure message, and `make
info` end-to-end.
- `fnm` branch is logically straightforward but was not exercised (no
fnm on the test box) — worth a smoke test if you have one.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Matt Godbolt <matt@godbolt.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-02 19:50:58 +01:00
Matt Godbolt
7785165903 Bump Node floor to v22 (#8764)
Raises Compiler Explorer's minimum Node version from 20 to 22, aligning
the declared floor with what production actually runs (Node 22.13.1
across the fleet).

## Why
- Production already runs Node 22.13.1 everywhere; the declared floor
(`>=20`) lagged reality.
- It's a prerequisite for upcoming dependency majors — commander 15
requires Node >=22.12.

## Changes
- `package.json`: `engines.node` `>=20.0.0` → `>=22.0.0`.
- `etc/scripts/find-node`: `NODE_MIN_VERSION` `20` → `22`.
- `.github/workflows/test-and-deploy.yml`: the `build_minimum_support`
job moves from Node 20.18.2 to 22.12.0 (the genuine floor), since
`find-node` now rejects Node <22.

Split out from the major-dependency PR (#8761) so it can land
independently. #8761 will rebase cleanly on top once this merges.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 17:43:16 -05:00
Matt Godbolt
3aeed42066 Upgrade to node 20 minimum, target node 22 (#7343)
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
2025-02-18 12:43:21 -06:00
Sam James
19440e35e3 etc: find-node: use command -v, not which (#6567)
`which` isn't in POSIX and some Linux distributions (e.g. Debian,
Gentoo) are trying to remove it from their base installs. See
https://lwn.net/Articles/874049/.
2024-06-08 15:30:59 -05:00
Matt Godbolt
5d776aaae3 Replace ts-node-esm with direct calls to node to support node 20 (#5521)
- works both v18 and v20
- see https://github.com/TypeStrong/ts-node/issues/1997
2023-09-27 21:57:18 -05:00
Matt Godbolt
fb4b7bb16e Bump used node version to 18 (#4778)
Still assume node 16 compatibility for now.
2023-02-25 12:43:00 -06:00
Matt Godbolt
bfa10e7afa Set our minimum node to 16 (#4005)
See #3995, seems we can't install on lower node any more?
2022-08-30 10:08:44 -05:00
Matt Godbolt
eabfdca2fc Bump to new LTS version 16 node 2022-01-10 22:38:43 -06:00
Matt Godbolt
dc1592cdc1 Update to node v14.18.0 (#3026)
* Update to node v14.18.0
2021-10-11 23:18:19 -05:00
Austin Morton
044dcfbf88 Use ES6 Modules (#2132) 2020-09-26 16:59:26 -04:00
Matt Godbolt
17e7f85d7a async aws; note that we're now using node 11 features 2020-01-14 22:06:04 -06:00
RabsRincon
77568f747b Simplify version checks 2019-12-23 09:52:59 +01:00
Rubén Rincón
f2e1384ea0 Add more descriptive messages to find-node script 2019-12-20 10:54:34 +01:00
Rubén Rincón
dc789ea9a6 Allow node verisons > 8, but recommend latest LTS 2019-12-20 10:45:30 +01:00
Rubén Rincón
4a3cd05ca0 Bump node version to LTS v12 2019-12-20 10:13:22 +01:00
Marc Poulhiès
b145fd6564 Do not use system node by error
If system's node is overriden by something in PATH, having NODE_DIR
empty will cause the script to still use node found in /bin/.
Only consider the first case if NODE_DIR is not empty.
2019-04-30 15:04:28 +02:00
RabsRincon
47b65b15d9 Upgrade to latest Node LTS (10) 2019-04-12 15:32:31 +02:00
Ruslan Garipov
42c9b269f0 Make ``find'' scripts compatible w/ the Bourne sh
By default FreeBSD does not have the Bourne-again shell (Bash)
installed.  Therefore, the system fails to execute two ``find'' scripts
(etc/scripts/find-node and etc/scripts/find-yarn) running by the
Makefile within the `.node-bin` and `.yarn-bin` targets.

I see nothing Bash-specific in those scripts.  Also I believe that
`[[ expression ]]` commands in those particular cases can be safely
replaced with the `test` built-in commands.

With these changes I can now run a local ``Compiler explorer'' instance
on FreeBSD.

Signed-off-by: Ruslan Garipov <ruslanngaripov@gmail.com>
2019-01-31 20:24:00 +05:00
Matt Godbolt
d92ef4f2b6 Prevent creation of an empty .node-bin or .yarn-bin if the version check fails. Helps with #850 2018-03-05 08:14:17 -06:00
Matt Godbolt
f8468e5d92 Use a local-installed yarn. Refactor all the 'find node' stuff out of the Makefile 2018-02-10 17:10:56 -06:00