• npm package.json


    1 Description

    This document is all you need to know about what’s required in your package.json file. It must be actual JSON, not just a JavaScript object literal.

    A lot of the behavior described in this document is affected by the config settings described in config.

    2 name

    If you plan to publish your package, the most important things in your package.json are the name and version fields as they will be required. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. If you don’t plan to publish your package, the name and version fields are optional.

    The name is what your thing is called.

    待补充

    3 version

    If you plan to publish your package, the most important things in your package.json are the name and version fields as they will be required. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. If you don’t plan to publish your package, the name and version fields are optional.

    Version must be parseable by node-semver, which is bundled with npm as a dependency. (npm install semver to use it yourself.)

    4 description

    Put a description in it. It’s a string. This helps people discover your package, as it’s listed in npm search.

    5 keywords

    Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in npm search.

    9 people fields: author, contributors

    The “author” is one person. “contributors” is an array of people. A “person” is an object with a “name” field and optionally “url” and “email”, like this:

    {
      	"name" : "Barney Rubble",
      	"email" : "b@rubble.com",
      	"url" : "http://barnyrubble.tumblr.com/"
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    Or you can shorten that all into a single string, and npm will parse it for you:

    {
      	"author": "Barney Rubble  (http://barnyrubble.tumblr.com/)"
    }
    
    • 1
    • 2
    • 3

    Both email and url are optional either way.

    npm also sets a top-level “maintainers” field with your npm user info.

    12 main

    The main field is a module ID that is the primary entry point to your program. That is, if your package is named foo, and a user installs it, and then does require("foo"), then your main module’s exports object will be returned.

    This should be a module relative to the root of your package folder.

    For most modules, it makes the most sense to have a main script and often not much else.

    If main is not set it defaults to index.js in the package’s root folder.

    18 scripts

    The “scripts” property is a dictionary containing script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.

    See scripts to find out more about writing package scripts.

    20 dependencies

    Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.

    Please do not put test harnesses or transpilers or other “development” time tools in your dependencies object. See devDependencies, below.

    See semver for more details about specifying version ranges.

    • version Must match version exactly
    • >version Must be greater than version
    • >=version etc
    • <=version
    • ~version “Approximately equivalent to version” See semver
    • ^version “Compatible with version” See semver
    • 1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
    • http://... See ‘URLs as Dependencies’ below
    • * Matches any version
    • "" (just an empty string) Same as *
    • version1 - version2 Same as >=version1 <=version2
    • range1 || range2 Passes if either range1 or range2 are satisfied.
    • git... See ‘Git URLs as Dependencies’ below
    • user/repo See ‘GitHub URLs’ below
    • tag A specific version tagged and published as tag See npm dist-tag
    • path/path/path See Local Paths below

    For example, these are all valid:

    {
      "dependencies": {
        "foo": "1.0.0 - 2.9999.9999",
        "bar": ">=1.0.2 <2.1.2",
        "baz": ">1.0.2 <=2.3.4",
        "boo": "2.0.1",
        "qux": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0",
        "asd": "http://asdf.com/asdf.tar.gz",
        "til": "~1.2",
        "elf": "~1.2.3",
        "two": "2.x",
        "thr": "3.3.x",
        "lat": "latest",
        "dyl": "file:../dyl"
      }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
  • 相关阅读:
    离线语音识别PocketSphinx(一)
    ShardingSphere 集成 CosId 实战
    LeetCode 0179. 最大数
    【亲测有效】CentOS7 安装supervisor守护进程管理器 自动开机运行
    11.MySQL多表查询简介
    Python小功能实现(链接下载图品并存储到EXCEL中)
    【蒸汽冷凝器型号和PI控制】具有PID控制的蒸汽冷凝器的动力学模型(Matlab&Simulink)
    在OCP集群中安装NSX ALB AKO
    C语言打印日志0718
    java版直播商城平台规划及常见的营销模式有哪些?电商源码/小程序/三级分销
  • 原文地址:https://blog.csdn.net/kking_edc/article/details/126219646