Notes
  • 速记
  • 前端面试
  • HTML / CSS
    • HTML
    • CSS
    • CSS Modules
      • CSS Modules
        • CSS Modules Usage
      • Stylus
      • Nunjucks
  • Javascript
    • 正则表达式
    • 代理(Proxy)和反射(Reflection)
    • 类型转换
    • 按位操作
    • 数据可视化
    • 数据采集
      • 无(全)埋点
      • 模块曝光事件
    • package
      • axios
    • Event Loop
    • React
      • React热身
      • VDOM和DOM-diff
    • Vue
    • Omi
    • MVVM
    • 百度小程序
    • AST抽象语法树
    • ServiceWorker
    • WebSocket
  • NodeJS
    • Assert 断言
    • chai.js 断言库
    • Node Global Obj And Var
    • CLI Writed By Nodejs
    • Framework
      • Hapi Js Framework
    • Electrode JS
      • Electrode Platform
      • Electrode Question
    • Redux
      • Redux Basic Usage
      • Middleware And Asynchronous
      • React-Redux 的用法
    • NPM
      • package.json
      • semver
    • Webpack
      • 编写插件
    • 同构渲染
    • 调用DLL
  • 服务端
    • Inotify
    • Linux
    • Nginx
      • Nginx简介
      • Nginx原理、安装预配置
    • TCP/IP 协议
    • HTTP 协议
      • 基础概念篇
      • 协议详解篇
    • Process
      • 阻塞与非阻塞
      • 进程与线程优性能
  • 数据库
    • GraphQL
  • 移动端
  • 微信小程序
    • 微信小程序安装(linux)
    • 小程序第三方框架
  • 开发工具
    • 开发工具安装
    • Vim Command Collection
    • Git
      • Git Rule
      • Git Submodule
      • gitignore
    • Lerna
    • Ubuntu开发环境安装
  • 运维测试
    • Docker
      • Docker Synopsis
      • docker.sock
    • Nightwatch
    • Jest
  • 算法/数学/架构
    • 设计模式
    • 架构设计经验分享
    • 前端架构
    • 基本数据结构
    • 函数式编程
  • 软件工程
    • 软件生命周期
Powered by GitBook
On this page
  • name
  • version
  • description
  • keywords
  • homepage
  • bugs
  • license
  • author, contributors
  • files
  • always included files
  • always ignored files
  • main
  • browser
  • bin
  • man
  • directories
  • directories.lib
  • directories.bin
  • directories.man
  • directories.doc
  • directories.example
  • directories.test
  • repository
  • scripts
  • config
  • dependencies
  • devDependencies
  • peerDependencies
  • bundledDependencies
  • optionalDependencies
  • engines
  • engineStrict
  • os
  • cpu
  • preferGlobal
  • private
  • publishConfig

Was this helpful?

  1. NodeJS
  2. NPM

package.json

name

  • The name must be less than or equal to 214 characters. This includes the scope for scoped packages.

  • The name can't start with a dot or an underscore.

  • New packages must not have uppercase letters in the name.

  • The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters.

version

description

keywords

homepage

bugs

{
  "url" : "https://github.com/owner/project/issues",
  "email" : "project@hostname.com"
}

license

author, contributors

{
  "name" : "Barney Rubble",
  "email" : "b@rubble.com",
  "url" : "http://barnyrubble.tumblr.com/"
}

// shorten
"Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"

files

files > .npmignore > .gitignore

always included files

  • package.json

  • README

  • CHANGES / CHANGELOG /HISTORY

  • LICENSE / LICENCE

  • NOTICE

  • The file in the "main" field

always ignored files

  • .git

  • CVS

  • .svn

  • .hg

  • .lock-wscript

  • .wafpickle-N

  • .*.swp

  • .DS_Store

  • ._*

  • npm-debug.log

  • .npmrc

  • node_modules

  • config.gypi

  • *.orig

  • package-lock.json (use shrinkwrap instead)

main

browser

bin

{ "bin" : { "myapp" : "./cli.js" } }

If you have a single executable, and its name should be the name of the package, then you can just supply it as a string

{
  "name": "my-program",
  "version": "1.2.5",
  "bin": "./path/to/program"
}

would be the same as this:

{
  "name": "my-program",
  "version": "1.2.5",
  "bin" : { "my-program" : "./path/to/program" }
  }

man

Specify either a single file or an array of filenames to put in place for the man program to find

directories

directories.lib

directories.bin

directories.man

directories.doc

directories.example

directories.test

repository

"repository": {
  "type" : "git",
  "url" : "https://github.com/npm/cli.git"
}

"repository": {
  "type" : "svn",
  "url" : "https://v8.googlecode.com/svn/trunk/"
}

"repository": {
  "type" : "git",
  "url" : "https://github.com/facebook/react.git",
  "directory": "packages/react-dom"
}

shortcut syntax

"repository": "npm/npm"

"repository": "github:user/repo"

"repository": "gist:11081aaa281"

"repository": "bitbucket:user/repo"

"repository": "gitlab:user/repo"

scripts

config

dependencies

devDependencies

peerDependencies

bundledDependencies

optionalDependencies

engines

{
  "engines" : { "node" : ">=0.10.3 <0.12" }
  }

engineStrict

This feature was removed in npm 3.0.0

os

process.platform

// white list
"os" : [ "darwin", "linux" ]

// black list
"os" : [ "!win32" ]

cpu

process.arch

preferGlobal

DEPRECATED

private

publishConfig

PreviousNPMNextsemver

Last updated 5 years ago

Was this helpful?