Skip to content

Commit 93c6394

Browse files
docs: added a note about importing the module in TypeScript (#474)
1 parent 9eebdc7 commit 93c6394

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,20 @@ Note: When using Node that supports [conditional exports](https://nodejs.org/api
5555

5656
#### Use in **TypeScript**:
5757

58-
Import or require based on the environment (see above).
58+
Import or require based on the environment (see above). If you want to use the CommonJS module syntax (`require`), you'll need to install the Node.js types from the `DefinitelyTyped` repository.
59+
60+
```
61+
npm install @types/node
62+
```
63+
64+
If you want to use the ESM syntax (`import`), you will need to include the following options in your `tsconfig.json`.
65+
66+
```json
67+
{
68+
"allowSyntheticDefaultImports": true,
69+
"esModuleInterop": true
70+
}
71+
```
5972

6073
If you get errors stating: `Cannot find name 'BigInt'`, add [`"esnext.bigint"`](https://github.com/microsoft/TypeScript/blob/master/src/lib/esnext.bigint.d.ts) or [`"esnext"`](https://github.com/microsoft/TypeScript/blob/master/src/lib/esnext.d.ts) to your `tsconfig.json` file, under `"lib"`:
6174

0 commit comments

Comments
 (0)