龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

nodejs npm package.json中文文档_node.js(3)

时间:2014-09-11 12:00来源:网络整理 作者:网络 点击:
分享到:
将markdown文件放在这里。最后,这些会被很好地展示出来,也许,某一天。 Put markdown files in here. Eventually, these will be displayed nicely, maybe, someday. directories.e

将markdown文件放在这里。最后,这些会被很好地展示出来,也许,某一天。
Put markdown files in here. Eventually, these will be displayed nicely,
maybe, someday.

directories.example

将事例脚本放在这里。某一天,它可能会以聪明的方式展示出来。

repository

指定你的代码存放的地方。这个对希望贡献的人有帮助。如果git仓库在github上,那么npm docs命令能找到你。

这样做:

复制代码 代码如下:

"repository" :
  { "type" : "git"
  , "url" : "http://github.com/isaacs/npm.git"
  }
"repository" :
  { "type" : "svn"
  , "url" : "http://v8.googlecode.com/svn/trunk/"
  }

URL应该是公开的(即便是只读的)能直接被未经过修改的版本控制程序处理的url。不应该是一个html的项目页面。因为它是给计算机看的。

scripts

“scripts”是一个由脚本命令组成的hash对象,他们在包不同的生命周期中被执行。key是生命周期事件,value是要运行的命令。

参见 npm-scripts(7)

config

“config” hash可以用来配置用于包脚本中的跨版本参数。在实例中,如果一个包有下面的配置:

复制代码 代码如下:

{ "name" : "foo"
, "config" : { "port" : "8080" } }

然后有一个“start”命令引用了npm_package_config_port环境变量,用户可以通过npm config set foo:port 8001来重写他。

参见 npm-config(7) 和 npm-scripts(7)。

dependencies

依赖是给一组包名指定版本范围的一个hash。这个版本范围是一个由一个或多个空格分隔的字符串。依赖还可以用tarball或者git URL。

请不要将测试或过渡性的依赖放在dependencieshash中。见下文的devDependencies。

详见semver(7).

1.version 必须完全和version一致
2.>version 必须比version大
3.>=version 同上
4.<version 同上
5.<=version 同上
6.~version 大约一样,见semver(7)
7.1.2.x 1.2.0, 1.2.1, 等,但不包括1.3.0
8.http://... 见下文'依赖URL'
9.* 所有
10."" 空,同*
11.version1 - version2 同 >=version1 <=version2.
12.range1 || range2 二选一。
13.git... 见下文'依赖Git URL'
14.user/repo 见下文'GitHub URLs'
15.比如下面都是合法的:

复制代码 代码如下:

{ "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"
  }
}

依赖URL

可以指定一个tarball URL,这个tarball将在包被初始化的时候下载并初始化。

依赖Git URL

Git urls 可以是下面几种形式:

复制代码 代码如下:

git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish

commit-ish是可以被git checkout的任何tag、sha或者branch。默认为master。

GitHub URLs

精彩图集

赞助商链接