【问题标题】:What are these properties prefixing underscore used for in package.json?这些在 package.json 中使用下划线前缀的属性是什么?
【发布时间】:2017-07-26 07:39:39
【问题描述】:

我在 package.json 中发现这些属性前缀为下划线。它们是用来做什么的?为什么要在属性上加下划线前缀?

  "_from": "react-scripts@0.9.3",
  "_id": "react-scripts@0.9.3",
  "_inCache": true,
  "_location": "/react-scripts",
  "_nodeVersion": "6.0.0",
  "_npmOperationalInternal": {
    "host": "packages-18-east.internal.npmjs.com",
    "tmp": "tmp/react-scripts-0.9.3.tgz_1488303928068_0.6415497597772628"
  },
  "_npmUser": {
    "name": "gaearon",
    "email": "dan.abramov@gmail.com"
  },

【问题讨论】:

    标签: javascript node.js reactjs npm package.json


    【解决方案1】:

    这些是为包注册表保留的元数据。所有以 _ 或 $ 开头的属性都保留给包注册表以供他们自行决定使用。 wiki common "Reserved Properties" section 解释它。

    【讨论】:

      【解决方案2】:

      下划线是 package.json 的保留属性,用于保留键。 所以,Documentation of package.json 中明确提到了,我们不能以下划线开头。

      【讨论】:

        猜你喜欢
        • 2016-09-13
        • 2011-08-28
        • 1970-01-01
        • 2017-03-17
        • 1970-01-01
        • 1970-01-01
        • 2011-07-31
        • 1970-01-01
        • 2011-09-03
        相关资源
        最近更新 更多