Skip to content

Commit

Permalink
Update javascript-with-nodejs.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nrios14 authored Nov 11, 2024
1 parent 6b3b108 commit c2d5b05
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions user/languages/javascript-with-nodejs.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: Building a JavaScript and Node.js project
title: Build a JavaScript and Node.js project
layout: en

---

## What This Guide Covers

<aside markdown="block" class="ataglance">

Expand Down Expand Up @@ -32,7 +31,7 @@ This guide covers build environment and configuration topics specific to JavaScr
projects. Please make sure to read our [Onboarding](/user/onboarding/)
and [General Build configuration](/user/customizing-the-build/) guides first.
## Specifying Node.js versions
## Specify Node.js versions
The easiest way to specify Node.js versions is to use one or more of the latest
releases in your `.travis.yml`:
Expand All @@ -57,13 +56,13 @@ the Environment Reference pages:
* [Trusty](/user/reference/trusty/#javascript-and-nodejs-images)

If you need more specific control of Node.js versions in your build, use any
version installable by `nvm`. If your `.travis.yml` contains a version of
version that is installable by `nvm`. If your `.travis.yml` contains a version of
Node.js that `nvm` cannot install, such as `0.4`, the job errors immediately.

For a precise list of versions pre-installed on the VM, please consult "Build
system information" in the build log.

## Specifying Node.js versions using .nvmrc
## Specify Node.js versions using .nvmrc

Optionally, your repository can contain a `.nvmrc` file in the repository root
to specify which *single* version of Node.js to run your tests against.
Expand All @@ -88,11 +87,11 @@ In the case where no `package.json` file is present in the root folder, the defa
make test
```

### Yarn is supported
### Yarn Support

If `yarn.lock` exists, the default test command will be `yarn test` instead of `npm test`.

### Using other Test Suites
### Use other Test Suites

You can tell npm how to run your test suite by adding a line in `package.json`.
For example, to test using Vows:
Expand All @@ -103,7 +102,7 @@ For example, to test using Vows:
},
```

## Using Gulp
## Use Gulp

If you already use Gulp to manage your tests, install it and run the default
`gulpfile.js` by adding the following lines to your `.travis.yml`:
Expand All @@ -121,9 +120,9 @@ Travis CI uses [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com) to insta

> Note that there are no npm packages installed by default in the Travis CI environment.

### Using `npm`
### Use npm

#### Using a specific `npm` version
#### Use a specific npm version

Add the following to the [`before_install` phase](/user/job-lifecycle/) of `.travis.yml`:

Expand All @@ -133,15 +132,15 @@ before_install:
```
{: data-file=".travis.yml"}

### `npm ci` support
### Support for npm ci

If `package-lock.json` or `npm-shrinkwrap.json` exists and your npm version
supports it, Travis CI will use `npm ci` instead of `npm install`.

This command will delete your `node_modules` folder and install all dependencies
as specified in your lock file.

#### Caching with `npm`
#### Cache with npm

`npm` is now cached by default, in case you want to disable it, please add the following to your `.travis.yml`:

Expand All @@ -166,9 +165,9 @@ any new packages added to your `package.json` file.

Even when `script` is overridden, this shortcut is effective.

### Using `yarn`
### Use yarn

Travis CI detects use of [yarn](https://yarnpkg.com/).
Travis CI detects the use of [yarn](https://yarnpkg.com/).

If both `package.json` and `yarn.lock` are present in the current
directory, we run the following command _instead of_
Expand All @@ -185,7 +184,7 @@ If the job does not meet this requirement, `npm install` is used
instead.


#### Using a specific `yarn` version
#### Use a specific yarn version

Add the following to the [`before_install` phase](/user/job-lifecycle/) of `.travis.yml`:

Expand All @@ -196,7 +195,7 @@ before_install:
```
{: data-file=".travis.yml"}

#### Caching with `yarn`
#### Cache with yarn

```yaml
cache: yarn
Expand All @@ -216,7 +215,7 @@ cache:

For more information, refer to [Caching](/user/caching/) documentation.

### Using shrinkwrapped git dependencies
### Use shrinkwrapped git dependencies

Note that `npm install` can fail if a shrinkwrapped git dependency pointing to a
branch has its HEAD changed.
Expand Down

0 comments on commit c2d5b05

Please sign in to comment.