1
1
---
2
- title : Building a JavaScript and Node.js project
2
+ title : Build a JavaScript and Node.js project
3
3
layout : en
4
4
5
5
---
6
6
7
- ## What This Guide Covers
8
7
9
8
<aside markdown =" block " class =" ataglance " >
10
9
@@ -32,7 +31,7 @@ This guide covers build environment and configuration topics specific to JavaScr
32
31
projects. Please make sure to read our [Onboarding](/user/onboarding/)
33
32
and [General Build configuration](/user/customizing-the-build/) guides first.
34
33
35
- ## Specifying Node.js versions
34
+ ## Specify Node.js versions
36
35
37
36
The easiest way to specify Node.js versions is to use one or more of the latest
38
37
releases in your ` .travis.yml`:
@@ -57,13 +56,13 @@ the Environment Reference pages:
57
56
* [Trusty](/user/reference/trusty/#javascript-and-nodejs-images)
58
57
59
58
If you need more specific control of Node.js versions in your build, use any
60
- version installable by `nvm`. If your `.travis.yml` contains a version of
59
+ version that is installable by `nvm`. If your `.travis.yml` contains a version of
61
60
Node.js that `nvm` cannot install, such as `0.4`, the job errors immediately.
62
61
63
62
For a precise list of versions pre-installed on the VM, please consult "Build
64
63
system information" in the build log.
65
64
66
- # # Specifying Node.js versions using .nvmrc
65
+ # # Specify Node.js versions using .nvmrc
67
66
68
67
Optionally, your repository can contain a `.nvmrc` file in the repository root
69
68
to specify which *single* version of Node.js to run your tests against.
@@ -88,11 +87,11 @@ In the case where no `package.json` file is present in the root folder, the defa
88
87
make test
89
88
` ` `
90
89
91
- # ## Yarn is supported
90
+ # ## Yarn Support
92
91
93
92
If `yarn.lock` exists, the default test command will be `yarn test` instead of `npm test`.
94
93
95
- # ## Using other Test Suites
94
+ # ## Use other Test Suites
96
95
97
96
You can tell npm how to run your test suite by adding a line in `package.json`.
98
97
For example, to test using Vows :
@@ -103,7 +102,7 @@ For example, to test using Vows:
103
102
},
104
103
` ` `
105
104
106
- # # Using Gulp
105
+ # # Use Gulp
107
106
108
107
If you already use Gulp to manage your tests, install it and run the default
109
108
`gulpfile.js` by adding the following lines to your `.travis.yml` :
@@ -121,9 +120,9 @@ Travis CI uses [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com) to insta
121
120
122
121
> Note that there are no npm packages installed by default in the Travis CI environment.
123
122
124
- # ## Using ` npm`
123
+ # ## Use npm
125
124
126
- # ### Using a specific ` npm` version
125
+ # ### Use a specific npm version
127
126
128
127
Add the following to the [`before_install` phase](/user/job-lifecycle/) of `.travis.yml` :
129
128
@@ -133,15 +132,15 @@ before_install:
133
132
` ` `
134
133
{: data-file=".travis.yml"}
135
134
136
- # ## ` npm ci` support
135
+ # ## Support for npm ci
137
136
138
137
If `package-lock.json` or `npm-shrinkwrap.json` exists and your npm version
139
138
supports it, Travis CI will use `npm ci` instead of `npm install`.
140
139
141
140
This command will delete your `node_modules` folder and install all dependencies
142
141
as specified in your lock file.
143
142
144
- # ### Caching with ` npm`
143
+ # ### Cache with npm
145
144
146
145
`npm` is now cached by default, in case you want to disable it, please add the following to your `.travis.yml` :
147
146
@@ -166,9 +165,9 @@ any new packages added to your `package.json` file.
166
165
167
166
Even when `script` is overridden, this shortcut is effective.
168
167
169
- # ## Using ` yarn`
168
+ # ## Use yarn
170
169
171
- Travis CI detects use of [yarn](https://yarnpkg.com/).
170
+ Travis CI detects the use of [yarn](https://yarnpkg.com/).
172
171
173
172
If both `package.json` and `yarn.lock` are present in the current
174
173
directory, we run the following command _instead of_
@@ -185,7 +184,7 @@ If the job does not meet this requirement, `npm install` is used
185
184
instead.
186
185
187
186
188
- # ### Using a specific ` yarn` version
187
+ # ### Use a specific yarn version
189
188
190
189
Add the following to the [`before_install` phase](/user/job-lifecycle/) of `.travis.yml` :
191
190
@@ -196,7 +195,7 @@ before_install:
196
195
` ` `
197
196
{: data-file=".travis.yml"}
198
197
199
- # ### Caching with ` yarn`
198
+ # ### Cache with yarn
200
199
201
200
` ` ` yaml
202
201
cache: yarn
@@ -216,7 +215,7 @@ cache:
216
215
217
216
For more information, refer to [Caching](/user/caching/) documentation.
218
217
219
- # ## Using shrinkwrapped git dependencies
218
+ # ## Use shrinkwrapped git dependencies
220
219
221
220
Note that `npm install` can fail if a shrinkwrapped git dependency pointing to a
222
221
branch has its HEAD changed.
0 commit comments