Commit 6f8cc9dc authored by Nick Gaskill's avatar Nick Gaskill

Merge branch 'docs-add-yarn2-instructions' into 'master'

Document how to use GitLab registry with yarn v2

See merge request gitlab-org/gitlab!60155
parents 8c531e39 a35c2989
...@@ -43,7 +43,7 @@ The npm version is shown in the output: ...@@ -43,7 +43,7 @@ The npm version is shown in the output:
### Install Yarn ### Install Yarn
As an alternative to npm, you can install Yarn in your local environment by following the As an alternative to npm, you can install Yarn in your local environment by following the
instructions at [yarnpkg.com](https://classic.yarnpkg.com/en/docs/install). instructions at [classic.yarnpkg.com](https://classic.yarnpkg.com/en/docs/install).
When installation is complete, verify you can use Yarn in your terminal by When installation is complete, verify you can use Yarn in your terminal by
running: running:
...@@ -305,6 +305,46 @@ See the ...@@ -305,6 +305,46 @@ See the
[Publish npm packages to the GitLab Package Registry using semantic-release](../../../ci/examples/semantic-release.md) [Publish npm packages to the GitLab Package Registry using semantic-release](../../../ci/examples/semantic-release.md)
step-by-step guide and demo project for a complete example. step-by-step guide and demo project for a complete example.
## Configure the GitLab npm registry with Yarn 2
You can get started with Yarn 2 by following the documentation at
[https://yarnpkg.com/getting-started/install](https://yarnpkg.com/getting-started/install).
To publish and install with the project-level npm endpoint, set the following configuration in
`.yarnrc.yml`:
```yaml
npmScopes:
foo:
npmRegistryServer: "https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/"
npmPublishRegistry: "https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/"
npmRegistries:
//gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/:
npmAlwaysAuth: true
npmAuthToken: "<your_token>"
```
For the instance-level npm endpoint, use this Yarn 2 configuration in `.yarnrc.yml`:
```yaml
npmScopes:
foo:
npmRegistryServer: "https://gitlab.example.com/api/v4/packages/npm/"
npmRegistries:
//gitlab.example.com/api/v4/packages/npm/:
npmAlwaysAuth: true
npmAuthToken: "<your_token>"
```
In this configuration:
- Replace `<your_token>` with your personal access token or deploy token.
- Replace `<your_project_id>` with your project's ID, which you can find on the project's home page.
- Replace `gitlab.example.com` with your domain name.
- Your scope is `foo`, without `@`.
## Publishing packages with the same name or version ## Publishing packages with the same name or version
You cannot publish a package if a package of the same name and version already exists. You cannot publish a package if a package of the same name and version already exists.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment