Open
Description
What happened?
git clone https://github.com/browserbase/mcp-server-browserbase.git
cd mcp-server-browserbase/browserbase
nvm use 18
# or any Node 18.x LTSnpm ci && npm run build
node dist/cli.js --help
The TypeScript compilation itself succeeds, but the generated JS immediately throws:
file:///…/browserbase/dist/program.js:6
import pkg from '../package.json' with { type: 'json' };
^^^^
SyntaxError: Unexpected token 'with'
If I patch that to avoid the import‑assertion and rebuild, the next run crashes with:
ReferenceError: require is not defined in ES module scope
Why this happens
tsconfig.json
is configured with"module": "NodeNext"
+"resolveJsonModule": true
.
TypeScript 5.x therefore emitsimport … with { type: "json" }
intodist/
.package.json
declares"type": "module"
and"engines": { "node": ">=18" }
, so runtime is ESM but promises only Node ≥ 18.- JSON‑import assertions are officially supported only from Node 20.6 onward, so Node 18 LTS cannot execute the output.
Expected behaviour
Either…
- the project advertises “requires Node 20.6+” (update
package.json engines
and README), or - the build emits code that is runnable on Node 18 (e.g. change
module
to"CommonJS"
or readpackage.json
viafs.readFileSync
).
Repro matrix
Node version | npm run build |
node dist/… |
---|---|---|
18.x LTS | ✅ succeeds | ❌ SyntaxError (with { type: 'json' } ) |
20.5 | ✅ | ❌ same as above |
20.6 + | ✅ | ✅ runs |
Suggested fix
- Quick: bump
"engines.node"
inbrowserbase/package.json
to"^20.6.0"
and mention in README. - Long‑term: if Node 18 support is desired, change build target to CommonJS or replace the JSON import with:
JSON.parse(
require('fs').readFileSync(
new URL('../package.json', import.meta.url),
'utf-8'
)
);
Thanks for the great project!
Metadata
Metadata
Assignees
Labels
No labels