Skip to content
Newer
Older
100644 58 lines (40 sloc) 2.75 KB
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
1 # Appendix: package.json
023403b @jfhbrook [fix] anchor tags in appendices now consistent, after headers for ron…
jfhbrook authored
2 <a name='apx:package'></a>
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
3
a0fb3ea @jfhbrook [doc] Review and upgrade of every chapter to reflect current state of…
jfhbrook authored
4 **[package.json.jit.su](http://package.json.jit.su) is an interactive package.json properties explorer! Highly recommended.**
5
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
6 ## Understanding the package.json format
7 A package.json file describes your application, its dependencies, and other various application metadata. For a detailed spec on creating a package.json you can check out Isaac's fine documentation [here](https://github.com/isaacs/npm/blob/master/doc/developers.md#readme).
8
9 ## Preparing a package.json for your application
10
11 Nodejitsu requires that you create a valid [package.json](#package_json) for your application. The package.json will determine certain important pieces of information about your application which are required for deployment. Since sometimes it can get confusing when constructing your package.json file, we provide wizards in our CLI tool and on our website for creating one.
12
13 Here is an example of what your package.json might look like:
14
15
16 {
17 "name": "hellonode",
18 "subdomain": "hellonode",
19 "scripts": {
bafeaf0 @jfhbrook Updates to package.json docs
jfhbrook authored
20 "start": "node server.js"
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
21 },
22 "version": "0.0.0"
23 }
24
bafeaf0 @jfhbrook Updates to package.json docs
jfhbrook authored
25 Notice the "scripts" property? This is where you'll store information about specific scripts in your application. The "start" property indicates the script that will get called when your application is started. Usage is compatible with `npm start`.
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
26
27 ## Specifying dependencies in your package.json
28
29 If your application requires additional dependencies or third-party libraries, Nodejitsu fully supports npm module dependency resolution. All you have to do is list your dependencies the exact same way you would if you were packaging a module for npm. Here is an example of the same package.json with a few dependencies.
30
31
32 {
33 "name": "hellonode",
34 "subdomain": "hellonode",
35 "scripts": {
36 "start": "server.js"
37 },
38 "dependencies": {
c72268c @jfhbrook [fix] dependencies example in apx:package is now more idiomatic
jfhbrook authored
39 "async": "0.1.x",
40 "colors": "0.5.x",
41 "request": "1.9.x"
4ec1c3c @jfhbrook [minor] Fixed links in appendices
jfhbrook authored
42 },
43 "version": "0.0.0"
44 }
45
46 Your dependencies will be resolved when your application deploys to Nodejitsu.
9d2e122 @jfhbrook [doc] Nodejitsu-Specific package.json properties
jfhbrook authored
47
48 ## Nodejitsu-Specific package.json Properties
49
50 A few package.json properties have special behavior on the Nodejitsu platform:
51
52 * *subdomain*: Specify the subdomain for your hosted app's nodejitsu url (for example, `subdomain.nodejitsu.com`.
53 * *domains*: A list of custom domains for your hosted app. See <http://dns.nodejitsu.com>.
54 * *env*: Specify environment variables for your app (for example, NODE_ENV="production" is set by default).
55 * *scripts.start*: This field is also used for `npm start`. However, nodejitsu's current implementation takes a path, whereas npm's implementation takes a shell command.
56 * *analyze*: Set this to "false" to force jitsu to not analyze for the app's dependencies.
57
Something went wrong with that request. Please try again.