How do I add comments to package.json for npm install?

后端 未结 20 1386
悲哀的现实
悲哀的现实 2020-12-07 07:30

I\'ve got a simple package.json file and I want to add a comment. Is there a way to do this, or are there any hacks to make this work?



        
20条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 07:41

    This has recently been discussed on the Node.js mailing list.

    According to Isaac Schlueter who created npm:

    ... the "//" key will never be used by npm for any purpose, and is reserved for comments ... If you want to use a multiple line comment, you can use either an array, or multiple "//" keys.

    When using your usual tools (npm, yarn, etc.), multiple "//" keys will be removed. This survives:

    { "//": [
      "first line",
      "second line" ] }
    

    This will not survive:

    { "//": "this is the first line of a comment",
      "//": "this is the second line of the comment" }
    

提交回复
热议问题