The package.json configuration file in the project is detailed

Usually when we use the npm init command to create an npm program, a package.jsonfile is automatically generated. package.jsonThe file will describe all relevant information of the NPM package, including author, introduction, package dependencies, build and other information, in strict JSON format.

package.json file configuration instructions official website

  1. name: required, the name, the length must be less than or equal to 214 characters, cannot start with "." (dot) or "_" (underscore), and cannot contain uppercase letters.
  2. version: required, version. XYZ → [major, minor, patch] → [main version, minor version, patch version] such as: 1.2.3
  3. description: Item description, which is a string. Helps people find this package when using npm search.
  4. keywords: project keywords, which is an array of strings. Helps people find this package when using npm search.
  5. homepage: The url of the project home page .
  6. bugs: Bug submission address.
  7. license: A software license that lets users know their usage rights and restrictions.
  8. author: The project developer.
  9. contributors: project contributors.
  10. files: An array of filenames contained by the project.
  11. main: The default execution file of the project, such as require('webpack'); the webpack.js file in the lib directory will be loaded by default, if not set, the index.js file in the project and directory will be loaded by default.
  12. bin: The path of the executable file corresponding to the internal command.
  13. man: Provide help documentation for the system's man command. The filename of the help file must end with a number, or .gz if it is compressed.
  14. directories: The directory structure information required by the CommonJS package, showing the directory structure information of the project. Fields can be: lib, bin, man, doc, example. The values ​​are all strings.
  15. repository: project warehouse address.
  16. scripts: By setting this, NPM can call some command scripts and encapsulate some functions.
  17. config: Add some settings, which can be read by scripts, and the values ​​here will also be added to the environment variables of the system.
  18. dependencies: In the production environment, the packages that the project depends on to run. Use the following command to install: npm install --save packageName.
  19. devDependencies: Dependency packages that are only required in the development environment. Use the following command to install: npm install --save-dev packageName.
  20. peerDependencies: related dependencies, if your package is a plug-in, and users usually need these dependencies (plug-ins) when using your package, you can list the dependencies here.
  21. bundledDependencies : Bundled dependency packages, these bundled packages will also be released together when released.
  22. optionalDependencies: Even if these dependencies are not available, they can be installed and used normally.
  23. engines: Specifies the environment in which the package runs.
  24. os: Specifies which system platforms your package can run on.
  25. cpu: You can specify the cpu architecture on which the package runs.
  26. private: Iftruethis package is set, it will not be published to the NPM platform.
  27. publishConfig: This field is used to set some settings when publishing. This is especially handy if you wish to set specifictagorregistry.

as follows: 

{
  "name": "usercenter",
  "version": "1.0.0",
  "description": "manage usercenter",
  "keywords": ["angular","es6"],
  "homepage": "https://github.com/***",
  "bugs": {
    "url": "https://github.com/***",
    "email": "[email protected]"
  },
  "license": "ISC",
  "author": "xjx",
  "main": "src/index.html",
  "repository": {
    "type": "git",
    "url": "git clone [email protected]:usercenter.git ~/git/usercenter"
  },
  "scripts": {
    "init": "npm install",
    "install": "bower install",
    "start": "node src/server/app.js",
    "build": "gulp build"
  },
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "morgan": "^1.10.0",
    "serve-favicon": "^2.5.0"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-preset-env": "^1.7.0",
    "chalk": "^4.1.2",
    "gulp": "^4.0.2",
  }
}

Guess you like

Origin blog.csdn.net/xiaoxiong_jiaxin/article/details/119927318