From b0b1b5dbdfdc11d9d38dbbf3e09d4228aead9134 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 24 Oct 2024 14:45:38 +0800 Subject: [PATCH] docs: update message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- docs/guide/troubleshooting.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md index ceef400e9f3b19..1804b589ceb3ed 100644 --- a/docs/guide/troubleshooting.md +++ b/docs/guide/troubleshooting.md @@ -54,7 +54,8 @@ When importing a ESM only package by `require`, the following error happens. > Failed to resolve "foo". This package is ESM only but it was tried to load by `require`. -> "foo" resolved to an ESM file. ESM file cannot be loaded by `require`. +> Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/dependency.js from /path/to/vite.config.js not supported. +> Instead change the require of index.js in /path/to/vite.config.js to a dynamic import() which is available in all CommonJS modules. In Node.js <=22, ESM files cannot be loaded by [`require`](https://nodejs.org/docs/latest-v22.x/api/esm.html#require) by default.