2013-10-14 04:36:58 +02:00
|
|
|
---
|
2015-11-24 06:09:17 +01:00
|
|
|
title: package.json
|
2015-11-24 06:02:17 +01:00
|
|
|
category: Node.js
|
2017-08-30 13:00:41 +02:00
|
|
|
prism_languages: [json]
|
2020-07-04 15:33:09 +02:00
|
|
|
updated: 2020-06-23
|
2017-08-30 13:00:41 +02:00
|
|
|
weight: -3
|
2013-05-29 14:19:07 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
### Basic
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"name": "expo",
|
|
|
|
"description": "My package",
|
|
|
|
"version": "0.1.0",
|
|
|
|
"license": "MIT",
|
|
|
|
"keywords": ["http", "server"],
|
2017-08-30 13:59:55 +02:00
|
|
|
"author": "Rico Sta. Cruz <rstacruz@users.noreply.github.com>",
|
2017-08-30 13:00:41 +02:00
|
|
|
"engines": {
|
|
|
|
"node": ">=0.8.0"
|
|
|
|
},
|
|
|
|
"main": "index",
|
|
|
|
"bin": {
|
|
|
|
"command": "./bin/command"
|
|
|
|
},
|
|
|
|
"repository": {
|
|
|
|
"type": "git",
|
|
|
|
"url": "https://github.com/rstacruz/___.git"
|
|
|
|
},
|
|
|
|
}
|
|
|
|
```
|
|
|
|
{: data-line="2,3,4,5"}
|
|
|
|
|
|
|
|
Highlighted lines are required.
|
2013-05-29 14:19:07 +02:00
|
|
|
|
|
|
|
### Dependencies
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
```json
|
|
|
|
"dependencies": {
|
|
|
|
"colors": "*",
|
|
|
|
"flatiron": "0.1.x",
|
|
|
|
"flatiron": "~0.1.0",
|
|
|
|
"plates": "https://github.com/user/project/tarball/branch",
|
|
|
|
"stuff": "git://github.com/user/project.git#commit-ish"
|
|
|
|
},
|
|
|
|
```
|
|
|
|
|
|
|
|
```json
|
|
|
|
"devDependencies": { ··· },
|
|
|
|
"peerDependencies": { ··· },
|
|
|
|
"optionalDependencies": { ··· },
|
|
|
|
```
|
|
|
|
|
|
|
|
See [Semver cheatsheet](./semver) for explanation of version ranges.
|
2013-05-29 14:19:07 +02:00
|
|
|
|
|
|
|
### Scripts
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
```json
|
|
|
|
"scripts": {
|
|
|
|
"start": "node ./bin/xxx", /* npm start */
|
|
|
|
"test": "vows --spec --isolate", /* npm test */
|
|
|
|
"postinstall": "...",
|
|
|
|
"prepublish": "grunt build", /* after 'npm install' and before 'npm
|
|
|
|
publish' */
|
|
|
|
}
|
|
|
|
```
|
2013-05-29 14:19:07 +02:00
|
|
|
|
|
|
|
### Misc
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
```json
|
|
|
|
"private": true,
|
|
|
|
"preferGlobal": true
|
|
|
|
```
|
2013-05-29 14:19:07 +02:00
|
|
|
|
2016-08-11 12:26:59 +02:00
|
|
|
### Config
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
```json
|
2016-08-11 12:26:59 +02:00
|
|
|
{
|
|
|
|
"config": {
|
|
|
|
"foobar": "hello"
|
|
|
|
},
|
|
|
|
"scripts": {
|
|
|
|
"run": "echo $npm_package_config_foobar"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-30 13:00:41 +02:00
|
|
|
Keys in `config` are exposed as env vars to scripts.
|
|
|
|
|
2017-08-28 18:37:00 +02:00
|
|
|
## References
|
|
|
|
{: .-one-column}
|
|
|
|
|
|
|
|
* <http://package.json.nodejitsu.com/>
|
2014-07-15 15:35:11 +02:00
|
|
|
* `npm help package.json`
|
2017-08-28 18:37:00 +02:00
|
|
|
{: .-also-see}
|