What the agent does
Node.js 22 dropped the assert { type: 'json' } form of JSON imports; the keyword is now with. The old form is a syntax error, so the file that contains it cannot be loaded at all, and the message points at the word assert without saying why. The agent's first job is to find which file Node was loading. In zakjan/leaflet-lasso it is not application code. Line 1 of rollup.config.js is import pkg from './package.json' assert { type: 'json' };, and because package.json sets "type": "module", Rollup hands that config file to Node as a native ES module. On Node 22, npm run build, which is rimraf dist && rollup -c, stops with [!] SyntaxError: Unexpected identifier 'assert' before any bundling starts.
Next it works out who notices, because here the answer is nobody until release day. The same checkout on the same Node 22 passes npx jest: 5 suites, 54 tests. Jest reads jest.config.js and the TypeScript sources, never the Rollup config. The build is wired to prepublishOnly, so it runs when a maintainer publishes. The repository has no workflow that runs the build and no engines field saying which Node versions are expected. The agent writes this down plainly in its report: tests green, build broken, and the first person to find out would be whoever next runs npm publish.
There are two correct fixes and the agent chooses by evidence. Changing the keyword to with is the smallest edit, and with it the build completes on Node 22 and writes all five bundles the config declares, the CommonJS, ES module, UMD and minified UMD files and the type declarations. But Node's own ESM documentation dates with to 18.20, 20.10 and 21.0, so that edit trades one broken range of Node versions for another: a contributor on an earlier 18 or 20 release gets a syntax error at the new keyword. The second fix removes the question. Reading the file with readFileSync(new URL('./package.json', import.meta.url)) and JSON.parse uses no import syntax that has changed, and the config only needs pkg.main, pkg.module, pkg.browser, pkg.types and the two dependency lists from it. With no declared Node range to rely on, the agent takes the second fix; if you tell it the minimum is Node 22, it takes the first and adds an engines entry so the choice is recorded.
It finishes by comparing outputs, not just exit codes. It lists dist after building with each variant and checks the file names match, then searches the rest of the repository, sources, scripts and other config files, for any other assert { after an import so a second one does not surface later. If the project has a lockfile it installs with npm ci so the Rollup and plugin versions are the ones the maintainers last resolved.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "On Node.js 22 this project fails with \"SyntaxError: Unexpected identifier 'assert'\". Find every import that uses an import assertion (assert { type: ... }) in sources, scripts and config files, including build tool configs that Node loads directly. For each one, say which npm script or command loads that file. Install dependencies from the lockfile, then run every script in package.json that could load an affected file, plus the test script, on Node 22, and report which fail and which pass; if the tests pass while the build fails, say so explicitly. Read package.json engines, .nvmrc and any CI files to learn which Node versions the project supports. If a minimum of Node 22 (or 20.10 / 18.20 and later) is declared, change assert to with. If no range is declared or older versions are included, replace the JSON import with reading and parsing the file through node:fs and import.meta.url, which works on every Node version with ES modules. Do not change the bundler, its plugins or their versions. Rebuild and compare the list of files in the output directory with what the config declares. If no CI job runs the build, propose one in the pull request description but do not add it. Open a pull request with the failing output, the passing output, the file list and the reason for the variant you chose.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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
A pull request that usually changes one or two lines in a config file. For leaflet-lasso it replaces the first line of rollup.config.js. The description shows the build failing on Node 22 with the title's message, the test suite passing on the same Node, and the build succeeding after the edit with its dist listing. It states which fix was chosen and why, quoting the engines field or noting that there is none.
The reviewer checks that the built file names equal the ones package.json points to in main, module, browser and types, since a published package with a missing entry file is the real cost of this bug. They also read the note about CI. The agent does not add a workflow nobody asked for, but it says when the only command that exercises the broken file is one that runs at publish time.
Run it on every failed build after a Node.js upgrade
If your builds run in GitHub Actions, an automation in the Project with a github trigger on workflow_run.failure starts a run whenever a workflow fails. Rush adds the event after the saved prompt as third-party data. Keep the prompt strict: read the failed job's log, and continue only when it contains Unexpected identifier 'assert'; otherwise reply with one line and stop.
Where the build runs somewhere else, such as a release machine or another CI system, have that system's failure hook call a small handler on your server, and let the handler post the log excerpt to a webhook trigger with Authorization: Bearer and the trigger's secret. The posted body, up to 64 KB, becomes the event text the agent reads.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The bug is a disagreement between Node versions, and checking a fix properly means running the build on more than one of them. Switching runtimes on a laptop disturbs whatever else is open there. The sandbox starts clean, the agent installs the Node releases it needs, runs npm ci and the build under each, and nothing on your machine changes. Each command's output is kept with the session, so the claim that a variant works on a given Node is backed by the line that shows it.
It also surfaces the part a quick local fix skips. Someone who hits this at publish time edits the keyword, sees the build pass on their Node and moves on, and the next contributor on an older release inherits a new syntax error. The run reads the declared support range first, picks the variant that fits it, and tells you in the pull request that tests alone would never have caught the break.
Frequently asked questions
What replaced import assertions in Node.js?
Import attributes: the same statement with with in place of assert, as in import data from './data.json' with { type: 'json' }. Node's documentation lists with from 18.20, 20.10 and 21.0, and lists 22.0 as the release that dropped assert.
Why do my tests pass when the build fails?
Because the test runner never loads the file with the old syntax. In leaflet-lasso the assertion is in rollup.config.js, which only rollup -c reads. A syntax error is only raised when Node parses that particular file.
Is there a form that works on every Node version?
Yes, for JSON you control: read it with readFileSync(new URL('./file.json', import.meta.url), 'utf8') and JSON.parse. It uses no import syntax that changed between releases. createRequire(import.meta.url) then require('./file.json') is another.
Do I need to upgrade Rollup?
Not for this error. The syntax error is raised by Node while loading the config file, before Rollup's own code looks at it. The agent leaves the bundler and its plugins at the versions in your lockfile.
More jobs like this: Fix a bug from an alert
- Fix "error TS5102: Option 'importsNotUsedAsValues' has been removed" in tsconfig.json (TypeScript)
- Fix "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape" (NumPy)
- Fix "AttributeError: module 'inspect' has no attribute 'getargspec'" on Python 3.11 (inspect)
- Fix TypeError: Cannot Read Properties of Undefined (Reading 'FLAGS') in discord.js 14 (discord.js)
- Fix "NotImplementedError: interp2d has been removed in SciPy 1.14.0" (SciPy)
- Fix "SyntaxWarning: invalid escape sequence" on Python 3.12 (Python)