From 420fdea0cb495c2b269dd60c32e4a7363dc3a1fd Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Sat, 2 Dec 2023 23:57:51 +0900 Subject: [PATCH] docs: emphasize ESM interop --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84b5339d7..27aea63b4 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,19 @@ This is for you if you ever wanted: - Better interoperability in codebases that use ESM and CJS dependencies - Something really fast it's unnoticeable! +> [!TIP] +> **tsx is not just for TypeScript!** It also helps Node load `module` type packages. +> +> If you're getting the following error, give _tsx_ a try! +> ``` +> require('ESM package'); +> ^ +> +> Error [ERR_REQUIRE_ESM]: require() of ES Module from ./file.js not supported. +> Instead change the require of in ./file.js to a dynamic import() which is available in all CommonJS modules. +> ``` + + ### Quick start Try tsx now without setup! Just pass in a TypeScript file: @@ -46,7 +59,6 @@ npx tsx ./script.ts 2. Improve ESM <-> CJS interoperability as the ecosystem migrates to ESM 3. Support the [LTS versions of Node.js](https://endoflife.date/nodejs) - ## Install ### Local installation