Skip to content

常用的属性字段


<font style="color:rgb(0, 0, 0);">name</font>

语义版本控制准则

json
"repository": {
    "type": "git",
    "url": "git+https://github.com/Easybuoy/package.json-mastery.git"
  }

````
json
"scripts": {
    "start": "node index",
    "dev": "nodemon index",
    "test": "jest",
    "lint": "eslint ./server",
  }

json
"engines": {
  "npm": "6.10.0",
  "node": "10.14.1"
}

json
"dependencies": {
  "bcryptjs": "^2.4.3",
  "cors": "^2.8.5",
  "dotenv": "^6.1.0",
  "express": "^4.16.4",
}

关于版本号的规则如下:

语义控制规则:

  • ****
  • ****

json
"devDependencies": {
    "eslint": "^4.19.1",
    "mocha": "^6.2.0",
    "nodemon": "^1.19.1",
  }
````如何在项目中保证node/npm包版本相同?

json
peerDependencies:{
  vue:^2.5.16
}

`package.json``exports``exports`
json
{
  "exports": "./index.js"
}
  1. exports
json

{
  "exports": {
    ".": "./index.js",
    "./package.json": "./package.json",
    "./conditions": {
      "import": "./conditions.js",
      "require": "./conditions.cjs"
    }
  }
}
json
{
  "exports": {
    ".": "./index.js",
    "./subpath": "./subpath/index.js"
  }
}
json
{
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  }
}
json
{
  "exports": {
    ".": "./index.js",
    "./sub/*": "./sub/*.js"
  }
}
json
{
  "exports": {
    ".": "./index.js",
    "./alias": "./subpath/index.js"
  }
}
json
{
  "exports": {
    ".": {
      "node": {
        "import": "./dist/index-node.mjs",
        "require": "./dist/index-node.cjs"
      },
      "default": {
        "import": "./dist/index.mjs",
        "require": "./dist/index.cjs"
      }
    }
  }
}
`exports``exports`