---
title: "Comment by Manh Do on \"Why you should avoid CommonJs on your client-side javascript\" | Hashnode"
description: "Great article. How can I import a package which only publish their code as esm without having to set type: &quot;module&quot; in my package.json?"
url: "https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4/comment/61423cffb95e345575e9a40a"
---

[Discussion](https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4)

Comment [Why you should avoid CommonJs on your client-side javascript](https://hashnode.com/posts/why-you-should-avoid-commonjs-on-your-client-side-javascript/6140d977c5f31102b885d1d4)

[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
