Skip to content

Commit

Permalink
NPM/Yarn examples: Use lock file usually (#26699)
Browse files Browse the repository at this point in the history
Co-authored-by: hubwriter <hubwriter@github.com>
  • Loading branch information
SchulteMarkus and hubwriter authored Jul 21, 2023
1 parent c8897e5 commit 0a11854
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ If you don't specify a Node.js version, {% data variables.product.prodname_dotco

### Example using npm

This example installs the dependencies defined in the _package.json_ file. For more information, see [`npm install`](https://docs.npmjs.com/cli/install).
This example installs the versions in the _package-lock.json_ or _npm-shrinkwrap.json_ file and prevents updates to the lock file. Using `npm ci` is generally faster than running `npm install`. For more information, see [`npm ci`](https://docs.npmjs.com/cli/ci.html) and "[Introducing `npm ci` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)."

```yaml copy
steps:
Expand All @@ -147,10 +147,10 @@ steps:
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
run: npm ci
```

Using `npm ci` installs the versions in the _package-lock.json_ or _npm-shrinkwrap.json_ file and prevents updates to the lock file. Using `npm ci` is generally faster than running `npm install`. For more information, see [`npm ci`](https://docs.npmjs.com/cli/ci.html) and "[Introducing `npm ci` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)."
Using `npm install` installs the dependencies defined in the _package.json_ file. For more information, see [`npm install`](https://docs.npmjs.com/cli/install).

```yaml copy
steps:
Expand All @@ -160,12 +160,12 @@ steps:
with:
node-version: '18.x'
- name: Install dependencies
run: npm ci
run: npm install
```

### Example using Yarn

This example installs the dependencies defined in the _package.json_ file. For more information, see [`yarn install`](https://yarnpkg.com/en/docs/cli/install).
This example installs the dependencies defined in the _yarn.lock_ file and prevents updates to the _yarn.lock_ file. For more information, see [`yarn install`](https://yarnpkg.com/en/docs/cli/install).

```yaml copy
steps:
Expand All @@ -175,10 +175,10 @@ steps:
with:
node-version: '18.x'
- name: Install dependencies
run: yarn
run: yarn --frozen-lockfile
```

Alternatively, you can pass `--frozen-lockfile` to install the versions in the `yarn.lock` file and prevent updates to the `yarn.lock` file.
Alternatively, you can install the dependencies defined in the _package.json_ file.

```yaml copy
steps:
Expand All @@ -188,7 +188,7 @@ steps:
with:
node-version: '18.x'
- name: Install dependencies
run: yarn --frozen-lockfile
run: yarn
```

### Example using a private registry and creating the .npmrc file
Expand Down

0 comments on commit 0a11854

Please sign in to comment.