This error occurs because the module you are trying to require ('nanoid') is an ES module, but you are using it in a CommonJS module.

To resolve this issue, you can use the dynamic import() function instead of require() to import the 'nanoid' module.

Here's an example of how you can use dynamic import():

(async () => {
  const { nanoid } = await import('nanoid');
  // Use nanoid here
})();

Make sure to wrap the import statement in an async IIFE (Immediately Invoked Function Expression) as dynamic import() returns a promise

const nanoid = requirenanoid ^Error ERR_REQUIRE_ESM require of ES Module homeblackCatcodestestnode_modulesnanoidindexjs from homeblackCatcodestestappjs not supportedInstead change

原文地址: http://www.cveoy.top/t/topic/h02K 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录