DEV Community

Cover image for Package.json File explained!!!

Package.json File explained!!!

Naveenchandar on June 30, 2021

If you've been working on javascript or related framework projects then definitely you came across the file named package.json and we might be curi...
Collapse
 
lakshmananarumugam profile image
Lakshmanan Arumugam

Good article @naveenchandar . well explained each options with example. recent days one option added in package.json. This option also useful for now a days.

Example:

"resolutions": {
    "d2/left-pad": "1.1.1",
    "c/**/left-pad": "^1.1.2"
  }
Enter fullscreen mode Exit fullscreen mode

More info

Collapse
 
naveenchandar profile image
Naveenchandar

Yeah but this is available only on Yarn right?. Correct me if I'm wrong.

Collapse
 
lakshmananarumugam profile image
Lakshmanan Arumugam • Edited

Yes. I guess now a days most of the people using yarn only.

I Forgot to add this note: This option only useful for who using yarn package manager in their project.

Collapse
 
barelyhuman profile image
Reaper

small addition, a lot of people don't know about the
publishConfig key, you can use it to set the access and other variables so you can avoid doing the npm publish --access=public when working with scoped packages.

Might help someone.

Collapse
 
naveenchandar profile image
Naveenchandar

That's a great one to add ๐Ÿ‘.

Collapse
 
duhdugg profile image
Doug Elkin

The "homepage" property is used for a completely different purpose for projects using react-scripts. This is a bit frustrating, in my opinion.

Also, if your package is distributing both commonjs and ES modules, the "main" property should be the path to the commonjs module, and the "module" property should be the path to the ES module.

Collapse
 
naveenchandar profile image
Naveenchandar

Agreed ๐Ÿ‘.

Collapse
 
sakalpatil profile image
sakalpatil

@naveenchandar : its best article, I did found any course which explain the package.json like you. Now I have clear understanding of package.json thanks Naveen

Collapse
 
naveenchandar profile image
Naveenchandar

Thanks a lot. ๐Ÿ™

Collapse
 
forkbikash profile image
Bikash Mishra

Thanks for sharing

Collapse
 
naveenchandar profile image
Naveenchandar

Pleasure..๐Ÿ˜Š

Collapse
 
naveenchandar profile image
Naveenchandar

Thanks mate..I was not aware of fixpack earlier. Glad to know.๐Ÿ‘

Collapse
 
cenacr007_harsh profile image
KUMAR HARSH

Nice article.

Collapse
 
naveenchandar profile image
Naveenchandar

Thank you ๐Ÿ˜Š.

Collapse
 
goodok21 profile image
Alexander Eric

Nice article but please change the title ๐Ÿ˜…

Collapse
 
naveenchandar profile image
Naveenchandar

๐Ÿ˜ƒ.. I'm bad at creating title. Can you suggest me some good one ?๐Ÿ˜‰

Collapse
 
omarfarooq profile image
Mohammad Omar Farooq Khan

Some Titles :

  • What is Package.json ๐Ÿค”
  • Complete Explanation of Package.json
Collapse
 
goodok21 profile image
Alexander Eric

Depends on content of this article:

  • Simple explanation of the package.json
  • Package.json basics
Collapse
 
bernardbaker profile image
Bernard Baker

Setting it to private doesn't stop it being published. Unless you're only working on public packages.

Collapse
 
nicolasmontielf profile image
Nico Montiel

Great article man, Thank you very much!

Collapse
 
naveenchandar profile image
Naveenchandar

Thank you ๐Ÿ˜Š

Collapse
 
coder023 profile image
Mukul Borole

Nice article ๐Ÿ‘. This article revised all my concepts.

Collapse
 
naveenchandar profile image
Naveenchandar

Thank you..๐Ÿ˜Š