# Upgrade a Node.js App to Node 24

Yes. An agent finds every place your Node version is pinned, installs and starts the app on Node 24 in its sandbox, fixes what breaks and opens a pull request.

[Run this on Rush](https://cloud.getrush.ai/run/upgrade-node-version/nodejs/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts by finding every statement of which Node the app runs on, because they disagree more often than not. In an app shaped like OWASP/NodeGoat, `Dockerfile` has two stages that both start `FROM node:12-alpine`; `.github/workflows/e2e-test.yml` tests on a matrix of `10.x`, `12.x` and `14.x` with `actions/setup-node@v1`, and `lint.yml` runs `jshint@2.12.0` on `14.x`; `.travis.yml` still lists `v8`, `v10` and `v12`; `README.md` says the app requires Node v8 or above; and `package.json` has no `engines` field and the repository no `.nvmrc`. The agent lists all of these in the pull request as the inventory, including the ones that are absent, so a reviewer sees where the new version is declared and where it was never declared.

Then it reads what the runtime change could break. `package.json` depends on `express` `^4.13.4`, `mongodb` `^2.1.18` used through the callback form of `MongoClient.connect` in `server.js`, `bcrypt-nodejs`, `swig` through `consolidate`, `express-session`, `marked` `0.3.5` and `needle` `2.2.4`; the dev dependencies are `grunt` with `grunt-contrib-jshint`, `grunt-mocha-test` and `grunt-retire`, `mocha` `^2.4.5`, `cypress` `^3.3.1` and `selenium-webdriver` `^2.53.2`. None of the runtime dependencies is a native module, so the risk is in Node's own changes rather than in rebuilds. `npm test` is `grunt test`, which `Gruntfile.js` defines as `env:test` followed by `mochaTest:unit` over `test/unit/*.js`, a directory that does not exist, so the unit task passes without running anything; the real checks are `test:ci`, which runs Cypress against a started server, and `npx jshint .` with `esversion: 9` from `.jshintrc`. The agent says this in the pull request rather than reporting a green `npm test` as evidence.

With the inventory in hand it makes the change in one place at a time: `FROM node:24-alpine` in both Dockerfile stages, an `engines` field of `"node": ">=24"` in `package.json`, a `.nvmrc` with `24`, the workflow matrices set to `24.x` and `actions/setup-node` moved to a current major because `v1` predates the `node-version-file` input, and the README line. It leaves `.travis.yml` alone unless asked, since nothing runs it, and notes that in the body. Then it installs with `npm ci` under Node 24, starts a `mongo:4.4` container as `docker-compose.yml` does, seeds with `node artifacts/db-reset.js`, starts the server with `npm start`, and logs in through `/login` with one of the seeded accounts from `artifacts/db-reset.js`, which exercises the `mongodb` driver, `express-session` and `swig` rendering on the new runtime. It builds the Docker image and runs it against the same container, and runs `npx jshint .` as `lint.yml` does.

Only a failure it saw gets a dependency change. A deprecation warning on startup is quoted but not fixed by an upgrade of an unrelated package; a package that will not install or load on Node 24 is bumped to the first release that does, and the body says which error forced it. The Cypress 3 binary is a dev dependency of a different generation, and if `npm run cy:verify` fails on Node 24 the agent reports that as a blocked check rather than rewriting the end-to-end suite under a runtime upgrade. The pull request lists every file it changed, every command it ran with its output, and what remains blocked and why.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Upgrade this Node.js app to Node 24 and open a pull request. First inventory every place the runtime version is declared or should be: Dockerfiles, .nvmrc, package.json engines, every workflow under .github/workflows, .travis.yml and the README, and report the ones that are absent. Change each to Node 24, add .nvmrc and an engines field if missing, and move actions/setup-node to a current major where the workflow pins an old one. Read package.json, server.js, Gruntfile.js, docker-compose.yml and artifacts/db-reset.js to learn how the app starts and what npm test really runs. Install with npm ci on Node 24, start the database the compose file names in Docker, seed it, start the server, and log in through the app with a seeded account; build and run the Docker image too; run the linter the lint workflow runs. Bump a dependency only when it fails to install or load on Node 24, to the first release that works, and quote the error. Do not upgrade anything else. Open a pull request listing each changed file, every command with its output, and any check that remains blocked and why.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request changes the version pins and little else: both `FROM` lines in `Dockerfile`, the matrices in `e2e-test.yml` and `lint.yml`, a new `.nvmrc`, an `engines` field in `package.json` and the README sentence, plus the lockfile if a dependency had to move. The body starts with the inventory table, then the commands it ran with their output: `npm ci`, the server start and the login, the Docker build and run, `npx jshint .`, and any `cy:verify` result.

The repository's own workflows then run on the pull request with the new matrix, which is the check the agent cannot fake: `lint.yml` runs `jshint` on Node 24, and `e2e-test.yml` installs, starts MongoDB, starts the app and runs the Cypress suite on Node 24. A pull request whose end-to-end job is red is still useful; its body says whether the red is a Node 24 regression or a pre-existing failure, with the log line that decides it.

A reviewer checks that no dependency moved without a quoted error, that `.travis.yml` was either updated or explicitly left as dead configuration, and that the login step really went through the database driver rather than a static page. A dependency the agent bumped is read against its changelog before merge; a runtime upgrade should not become a dependency upgrade by accident.

## Run it on every new Node LTS line

When a Node major becomes the active LTS, a script on your server lists repositories through `GET /o/{org}/github`, reads each one's `.nvmrc`, `engines` or Dockerfile, and sends one `POST /o/{org}/sessions` per repository still on an older line, with this prompt and that repository in `resources`. Keep the selection in your script so an app already upgraded is not sent the same request next quarter.

Give each request a `request_id` that is a UUID v5 of the repository and the target version, so a retry returns the run it already started. A `webhook_url` on the key receives `run.completed` per run with `data.session_url`, from which the pull request is read; the script can start every repository at once, because past the key's `max_concurrent` (4 by default, up to 100) a session answers `202` with `status: "queued"` and starts, oldest first, when a slot frees.

## Why run it on Rush?

A runtime upgrade is mostly verification: install under the new Node, start the database, start the app, click through it, build the image, and read the warnings. That is an afternoon of a laptop pinned to a version you do not use yet. In a Rush sandbox the agent installs Node 24 cleanly, runs MongoDB in its own Docker, and every command and its output stays in the transcript, including the warnings you would otherwise scroll past.

Several services on the same old Node get several runs, each in its own sandbox with its own pull request, because the fix for one (a package that lost its Node 12 build) is rarely the fix for another. What you review is a diff of version pins and a body that says what was run and what, if anything, remains blocked.

## Frequently asked questions

### Will it upgrade my dependencies while it is at it?

No. It bumps a package only when that package fails to install or load on Node 24, to the first release that works, and quotes the error that forced it. Deprecation warnings are reported, not fixed by unrelated upgrades.

### What if npm test passes but tests nothing?

It says so. In NodeGoat `grunt test` runs Mocha over `test/unit/*.js`, which does not exist, so the agent treats the Cypress suite and the login it performed against the running server as the evidence, and names the empty task in the body.

### Does it need my MongoDB?

No. It starts the image your `docker-compose.yml` names in its own sandbox, seeds it with the repository's own script and points the app at it with `MONGODB_URI`. Nothing it does touches a database outside the sandbox.

### What about an old test runner that will not run on Node 24?

A dev dependency like Cypress 3 may not install its binary on a current Node. The agent reports that as a blocked check with the error, because replacing a test runner is a different change from a runtime upgrade. Ask for it in a follow-up on the same session if you want it done.

## More Node.js jobs

- [Write Unit Tests for a Node.js App](https://getrush.ai/run/write-unit-tests/nodejs/)
- [Add Account Lockout After Failed Logins to a Node.js App](https://getrush.ai/run/add-account-lockout/nodejs/)
- [Add CSRF Protection to a Node.js App](https://getrush.ai/run/add-csrf-protection/nodejs/)

## The same job on other stacks

- [Upgrade an Express App to Node 24](https://getrush.ai/run/upgrade-node-version/express/)
- [Upgrade a NestJS App to Node 24](https://getrush.ai/run/upgrade-node-version/nestjs/)

## More jobs like this: Upgrade dependencies weekly

- [Upgrade npm Dependencies in a Chrome Extension Project](https://getrush.ai/run/upgrade-npm-dependencies/chrome-extension/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
