| title | Use Node.js with Travis CI |
|---|---|
| layout | en |
The following is a guide to getting started with Travis CI using Node.js.
Before getting started, create a .travis.yml file and add it to the root directory of your Node.js project.
Specify Node.js as the language and version of Node.js the project will use to let Travis CI know you are building a Node.js project. Here is an example of the configuration:
language: node_js
node_js:
- "14"
- "16"
- "18"{: data-file=".travis.yml"}
Travis CI runs the default npm install command to install your dependencies.
install:
- npm install{: data-file=".travis.yml"}
Travis CI runs any test defined in your package.json file by default. Explicitly run the command as follows:
script:
- npm test{: data-file=".travis.yml"}
Once your .travis.yml file is configured, push it to your repository, and Travis CI will start running tests for each Node version specified.
Here is the complete example:
language: node_js
node_js:
- "14"
- "16"
- "18"
install:
- npm install
script:
- npm test{: data-file=".travis.yml"}
For more information on Node.js projects, see: