๐—™๐—ถ๐˜… ๐—ก๐—ผ๐—ฑ๐—ฒ.๐—ท๐˜€ ๐—˜๐—ฆ๐—  ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—น๐—ฎ๐˜‚๐—ฑ๐—ฒ

Node.js module errors waste time. You see ERR_REQUIRE_ESM. You edit the wrong file. The problem lives in your config.

AI often suggests a full rewrite. This is a mistake. Feed Claude your config and the error.

Force the AI to classify the root cause first. Use these categories:

Use a script to gather context. It checks your package.json. It checks your file extensions. Paste the result into Claude.

TypeScript errors often hit in production. Compare tsconfig and package.json. Use NodeNext for both fields.

For ESM-only packages, use dynamic imports. This avoids a full project conversion.

Test your prompts. Build a bug on purpose. Confirm the AI finds the right cause.

Source: https://dev.to/_7fb6011b57d383122b5a/diagnose-nodejs-commonjs-vs-esm-errors-with-claude-a-copy-paste-prompt-kit-errrequireesm-2fcd