-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
Sorry if there's an existing issue for this but I only found #793 which is closed. I believe this is the status quo:
- Users really want this. Look at this StackOverflow question - over 600 upvotes!
- None of the current workarounds are very good.
- It would be a (minor) breaking change.
The current workarounds are:
- You can officially add a single top-level key
"//". This sucks because I want more than one comment! - Various hacks to put comments inside script commands. This sucks because it only works for scripts, and it's also terrible.
- Use duplicate keys. This sucks because JSON's duplicate key handling is not well defined, and NPM will delete the duplicate keys if it modifies
package.json. - Generate
package.jsonfrom another file. This is probably the best solution right now but it means you can'tnpm install -Dstuff and it's an extra step.
These all really suck. This is an age-old feature request wanted by many many people.
As far as I understand it the reason NPM "can't" be changed to just support package.json5 or package.jsonc is that third party tools would get confused when they try to read package.json and it's not there. I can think of two solutions:
- When you run
npm, as well as generatingpackage-lock.jsonit also generatespackage.json(and this should be.gitignored if you also havepackage.json{5,c}). Are there any third party tools that want to modifypackage.json? - Just ask those third party tools to support
package.json{5,c}too. This is clearly a smaller problem than not allowing comments in NPM's most important config file forever.
JosefBud, andriyor, amazfs and alexanderceruttiJosefBud and andriyor
Metadata
Metadata
Assignees
Labels
No labels