---
title: "Discussion on \"Writing a JavaScript Module That Works in Both CommonJS and ESM\" | Hashnode"
description: "Discussion on \"Writing a JavaScript Module That Works in Both CommonJS and ESM\". Learn how to create a JavaScript module that supports both CommonJS and ESM, ensuring compatibility and longevity for your NPM packages"
url: "https://hashnode.com/posts/writing-a-javascript-module-that-works-in-both-commonjs-and-esm/67bfda8d99a5866c2e12517c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Writing a JavaScript Module That Works in Both CommonJS and ESM](https://radmanesh.hashnode.dev/writing-a-javascript-module-that-works-in-both-commonjs-and-esm?utm_source=hashnode&utm_medium=feed)

Learn how to create a JavaScript module that supports both CommonJS and ESM, ensuring compatibility and longevity for your NPM packages

Feb 27, 2025 · 3 min read · radmanesh.hashnode.dev  
Read the article

-   [#commonjs](https://hashnode.com/tag/commonjs)
-   [#javascript-modules](https://hashnode.com/tag/javascript-modules)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#commonjs-modules](https://hashnode.com/tag/commonjs-modules)

## Written by

[Arman Radmanesh](https://hashnode.com/@Radmanesh)

@Radmanesh · Norman, Oklahoma

  
[View profile](https://hashnode.com/@Radmanesh)

Developer and Researcher

Arman Radmanesh is a software engineer and researcher passionate about wearable technology and machine learning. He began coding at 13, starting with Basic.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
