DEV Community

Discussion on: The best time to npm init

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Thanks Zell for the article.
I've always thought those package.json properties were to be added manually (, which is how I have been doing 😅) but npm init auto generating them is easier & less error prone.

I was wondering about workaround of renaming package.json mentioned in "The second best time to npm init".

Initially I thought npm init would add new props, which it did.

first

But then I added bad props that are to be added by npm init manually, and they weren't overwritten (tried npm init with & without --force flag) but only added a missing property, keywords.

second?

So your flow below makes total sense 🙂

  1. rename the package.json the original
  2. 👉 then npm init to create a new one with correct metadata.
  3. 👉 then copy over metadata
  4. 👉 rename the original package.json
Collapse
 
zellwk profile image
Zell Liew 🤗

This is interesting. Thanks for testing and posting your tests :)