Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Error [ERR_REQUIRE_ESM]: require() of ES Module not supported

Change require() to dynamic import()

Quick Answer: Use import() instead of require() for ES Modules.

The error [ERR_REQUIRE_ESM]: require() of ES Module not supported is caused by attempting to use ES Modules in CommonJS environments. In your case, the Discord bot is using a CommonJS module structure.

🚀 How to Resolve This Issue

Method 1: Importing Discord Bot

  1. Step 1: Replace the require() statements with dynamic imports using import().

Method 2: Using ES Modules

  1. Step 1: Update the Discord bot to use ES Modules by replacing module.exports = { ... } with export default { ... };.

💡 Conclusion

By implementing one of the above methods, you should be able to resolve the [ERR_REQUIRE_ESM]: require() of ES Module not supported error and successfully run your Discord bot.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions