---
title: "Discussion on \"Why you should avoid CommonJs on your client-side javascript\" | Hashnode"
description: "Discussion on \"Why you should avoid CommonJs on your client-side javascript\". CommonJs and ECMAScript module are the most famous module system in the javascript ecosystem. Before we consider why we should not use the CommonJs module system on the client-side, let's look at what exactly CommonJs and ESM are and how do they work..."
url: "https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4"
---

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

Discussion

# [Why you should avoid CommonJs on your client-side javascript](https://pranshushah.hashnode.dev/why-you-should-avoid-commonjs-on-your-client-side-javascript?utm_source=hashnode&utm_medium=feed)

CommonJs and ECMAScript module are the most famous module system in the javascript ecosystem. Before we consider why we should not use the CommonJs module system on the client-side, let's look at what exactly CommonJs and ESM are and how do they work...

Sep 14, 2021 · 4 min read · pranshushah.hashnode.dev  
Updated Sep 27, 2021  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#angular](https://hashnode.com/tag/angular)
-   [#vuejs](https://hashnode.com/tag/vuejs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#typescript](https://hashnode.com/tag/typescript)

## Written by

[pranshu shah](https://hashnode.com/@pranshushah)

@pranshushah

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

frontend-engineer

## Responses 1

Markdown supported · ⌘↵ to post

[Manh Do](https://hashnode.com/@codart)

[Sep 15, 2021](https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4/comment/61423cffb95e345575e9a40a)

Great article. How can I import a package which only publish their code as esm without having to set type: "module" in my package.json?

[pranshu shah](https://hashnode.com/@pranshushah)

[Sep 16, 2021](https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4/comment/61423cffb95e345575e9a40a#reply-6142f87c9c949972b85c85b8)

I think you can use `.mjs` extension to tell JavaScript engine that this file is ESM module not a script file. but I think setting `type: module` in package.json is better option
