Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM/Yarn examples: Use lock file usually #26699

Merged
merged 7 commits into from
Jul 21, 2023
Merged
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).
SchulteMarkus marked this conversation as resolved.
Show resolved Hide resolved

```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