diff --git a/src/content/docs/en/5x/starter/installing.mdx b/src/content/docs/en/5x/starter/installing.mdx index 27a32d62dd..5ec6a3f806 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: