From 54739522e415c1b8ed159a889fefef4e2c3fe40e Mon Sep 17 00:00:00 2001 From: Jameel Ahmad Date: Thu, 30 Jul 2026 13:44:58 +0500 Subject: [PATCH 1/2] docs: add missing package.json "type": "module" step to TypeScript install guide The TypeScript setup section provides a tsconfig.json using "module": "nodenext" and demonstrates ESM import syntax in src/app.ts, but doesn't mention that package.json also needs "type": "module" set. Without it, TypeScript treats .ts files as CommonJS by default and throws ECMAScript imports and exports cannot be written in a CommonJS file under 'verbatimModuleSyntax'. (ts1295) when following the guide as written. This adds the missing step so the example works out of the box. Signed-off-by: Jameel Ahmad --- src/content/docs/en/5x/starter/installing.mdx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/content/docs/en/5x/starter/installing.mdx b/src/content/docs/en/5x/starter/installing.mdx index e320885aca..7ea2088d77 100755 --- a/src/content/docs/en/5x/starter/installing.mdx +++ b/src/content/docs/en/5x/starter/installing.mdx @@ -52,6 +52,25 @@ for example `@types/cors` alongside `cors`. +Since the `tsconfig.json` below uses `"module": "nodenext"`, TypeScript determines whether each +file is treated as an ES Module or CommonJS based on the `"type"` field in your `package.json`. +Add `"type": "module"` to your `package.json` so that ES Module `import`/`export` syntax is +recognized: + +```json title="package.json" +{ + "type": "module" +} +``` + + + +Without `"type": "module"`, TypeScript will treat `.ts` files as CommonJS and report an error like +`ECMAScript imports and exports cannot be written in a CommonJS file under 'verbatimModuleSyntax'` +when you use `import`/`export` syntax. + + + Add a `tsconfig.json`. These options mirror how Node.js runs TypeScript and make the compiler reject non-erasable syntax (such as `enum`s, namespaces, and parameter properties) that Node cannot strip: From f6a884b176ec869a1f49dd65423fe244a489e7fc Mon Sep 17 00:00:00 2001 From: Jameel Ahmad Date: Sun, 25 Oct 2026 00:20:25 +0500 Subject: [PATCH 2/2] docs: note that npm init defaults "type" to "commonjs" --- src/content/docs/en/5x/starter/installing.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/5x/starter/installing.mdx b/src/content/docs/en/5x/starter/installing.mdx index 7ea2088d77..a20c4a7350 100755 --- a/src/content/docs/en/5x/starter/installing.mdx +++ b/src/content/docs/en/5x/starter/installing.mdx @@ -54,8 +54,12 @@ for example `@types/cors` alongside `cors`. Since the `tsconfig.json` below uses `"module": "nodenext"`, TypeScript determines whether each file is treated as an ES Module or CommonJS based on the `"type"` field in your `package.json`. -Add `"type": "module"` to your `package.json` so that ES Module `import`/`export` syntax is -recognized: +Recent versions of `npm init` set `"type": "commonjs"` by default, so change it to `"module"` so +that ES Module `import`/`export` syntax is recognized: + +```bash +npm pkg set type=module +``` ```json title="package.json" {