包描述性文件 package.json
定义
name:包名(必须是唯一的防止对外公布时产生冲突)
description:包简介
version:版本号
keywords:关键词数组
repositories:托管源代码位置列表
author:包作者
bin:一些包作者希望包可以作为命令行工具使用,配置好bin字段后,通过 npm install name -g 后可以将添加到执行路径中,之后可以再命令行中直接执行
main:模块引入方法require()在引入包时,会优先检查这个字段,并将其作为包中其余模块的入口,若该没有默认为index
dependencies:使用当前宝所需要的依赖的包列表(重要)
devDependencies:使用当前宝所需要的依赖的包列表(重要)
engine:支持引擎列表
script:脚本说明对象。主要被包管理器用来安装、编译、测试和卸载包。
例子
express项目的package.json文件
{ "name": "express", "description": "Sinatra inspired web development framework", "version": "3.3.4", "author": "TJ Holowaychuk <tj@vision-media.ca>", "contributors": [ { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" }, { "name": "Ciaran Jessup", "email": "ciaranj@gmail.com" }, { "name": "Guillermo Rauch", "email": "rauchg@gmail.com" } ], "dependencies": { "connect": "2.8.4", "commander": "1.2.0", "range-parser": "0.0.4", "mkdirp": "0.3.5", "cookie": "0.1.0", "buffer-crc32": "0.2.1", "fresh": "0.1.0", "methods": "0.0.1", "send": "0.1.3", "cookie-signature": "1.0.1", "debug": "*" }, "devDependencies": { "ejs": "*", "mocha": "*", "jade": "0.30.0", "hjs": "*", "stylus": "*", "should": "*", "connect-redis": "*", "marked": "*", "supertest": "0.6.0" }, "keywords": [ "express", "framework", "sinatra", "web", "rest", "restful", "router", "app", "api" ], "repository": "git://github.com/visionmedia/express", "main": "index", "bin": { "express": "./bin/express" }, "scripts": { "prepublish": "npm prune", "test": "make test" }, "engines": { "node": "*" } }