Skip to content

Commit 13613b4

Browse files
authored
fix: support node20 (#52)
Initially, we started with the support of Node22+ but since Node20 is an LTS that is still in the maintenance mode it makes sense to support it.
1 parent 7765bb3 commit 13613b4

File tree

9 files changed

+56
-9
lines changed

9 files changed

+56
-9
lines changed

.github/workflows/run-tests.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- windows-latest
2121
- macos-latest
2222
node:
23-
- 22.12.0
23+
- 20
2424
- 22
2525
- 23
2626
- 24
@@ -34,19 +34,34 @@ jobs:
3434
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3535
with:
3636
cache: npm
37-
node-version: ${{ matrix.node }}
37+
node-version: 22 # build works only with 22+.
3838

3939
- name: Install dependencies
4040
shell: bash
4141
run: npm ci
4242

43+
- name: Build
44+
run: npm run build
45+
46+
- name: Set up Node.js
47+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
48+
with:
49+
cache: npm
50+
node-version: ${{ matrix.node }}
51+
4352
- name: Disable AppArmor
4453
if: ${{ matrix.os == 'ubuntu-latest' }}
4554
shell: bash
4655
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
4756

57+
- name: Run tests (node20)
58+
if: ${{ matrix.node == '20' }}
59+
shell: bash
60+
run: npm run test:node20
61+
4862
- name: Run tests
4963
shell: bash
64+
if: ${{ matrix.node != '20' }}
5065
run: npm run test
5166

5267
# Gating job for branch protection.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ MCP clients.
2727

2828
## Requirements
2929

30-
- [Node.js 22.12.0](https://nodejs.org/) or newer.
30+
- [Node.js 20](https://nodejs.org/) or a newer [latest maintainance LTS](https://github.com/nodejs/Release#release-schedule) version.
3131
- [Chrome](https://www.google.com/chrome/) current stable version or newer.
3232
- [npm](https://www.npmjs.com/).
3333

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
1515
"start": "npm run build && node build/src/index.js",
1616
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
17+
"test:node20": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test build/tests",
1718
"test": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
1819
"test:only": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
1920
"test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
@@ -37,6 +38,7 @@
3738
"mcpName": "io.github.ChromeDevTools/chrome-devtools-mcp",
3839
"dependencies": {
3940
"@modelcontextprotocol/sdk": "1.18.2",
41+
"core-js": "3.45.1",
4042
"debug": "4.4.3",
4143
"puppeteer-core": "24.22.3",
4244
"yargs": "18.0.0"
@@ -53,14 +55,14 @@
5355
"@typescript-eslint/parser": "^8.43.0",
5456
"chrome-devtools-frontend": "1.0.1520535",
5557
"eslint": "^9.35.0",
56-
"eslint-plugin-import": "^2.32.0",
5758
"eslint-import-resolver-typescript": "^4.4.4",
59+
"eslint-plugin-import": "^2.32.0",
5860
"globals": "^16.4.0",
5961
"prettier": "^3.6.2",
6062
"puppeteer": "24.22.3",
6163
"sinon": "^21.0.0",
62-
"typescript-eslint": "^8.43.0",
63-
"typescript": "^5.9.2"
64+
"typescript": "^5.9.2",
65+
"typescript-eslint": "^8.43.0"
6466
},
6567
"engines": {
6668
"node": ">=22.12.0"

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ import {version} from 'node:process';
1010

1111
const [major, minor] = version.substring(1).split('.').map(Number);
1212

13-
if (major < 22 || (major === 22 && minor < 12)) {
13+
if (major === 22 && minor < 12) {
1414
console.error(
15-
`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 22.12.0 or newer.`,
15+
`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 22.12.0 LTS or a newer LTS.`,
16+
);
17+
process.exit(1);
18+
}
19+
20+
if (major < 20) {
21+
console.error(
22+
`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 20 LTS or a newer LTS.`,
1623
);
1724
process.exit(1);
1825
}

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import './polyfill.js';
8+
79
import assert from 'node:assert';
810
import fs from 'node:fs';
911
import path from 'node:path';

src/polyfill.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google Inc.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import 'core-js/modules/es.promise.with-resolvers.js';
8+
import 'core-js/proposals/iterator-helpers.js';

tests/setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright 2025 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
import '../src/polyfill.js';
7+
68
import path from 'node:path';
79
import {it} from 'node:test';
810

tests/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright 2025 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
76
import logger from 'debug';
87
import type {Browser} from 'puppeteer';
98
import puppeteer from 'puppeteer';

0 commit comments

Comments
 (0)