Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 1.38 KB

File metadata and controls

66 lines (49 loc) · 1.38 KB
title Use Node.js with Travis CI
layout en

The following is a guide to getting started with Travis CI using Node.js.

Prerequisite

Before getting started, create a .travis.yml file and add it to the root directory of your Node.js project.

Specify the Language

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

Install Build Dependencies

Travis CI runs the default npm install command to install your dependencies.

install:
 - npm install

{: data-file=".travis.yml"}

Define the Test Command

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

Commit and Push

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

Further Reading

For more information on Node.js projects, see: