gitea-guide/README.md

65 lines
2.0 KiB
Markdown
Raw Normal View History

2023-04-28 20:40:24 +03:00
# Setting up yarn v3 to work with Gitea
Instead of using Yarn Classic (V1), we are using V3 for working with new projects. This is for the reason that Yarn Classic is annoying when working with Gitea repositories and shouldn't really be bothered with.
The guide to installing and configuring Yarn V3 follows.
# Install guide
Checkout [tl;dr](./TLDR.md) if you are about to fall asleep.
You should first deinstall the current version of yarn which you are using. If you have legacy repositories with aliased package names (e.g. `"my-package": "npm:@scope/my-package"`), then you should look into use `corepack` on using an older Yarn version on that specific repository.
If you have Node 16.10 or higher, you should already have a program called [**Corepack**](https://nodejs.org/dist/latest/docs/api/corepack.html). If you don't, read the section "Node.js <16.10" below. Otherwise, enable as stated in the section after it.
### Node.js <16.10
Corepack isn't included with Node.js in versions before the 16.10; to address that, run:
```bash
npm i -g corepack
corepack prepare yarn@<version> --activate
yarn --version
```
### Node.js >=16.10
Corepack is included by default with all Node.js installs, but is currently opt-in. To enable it, run the following command:
```bash
corepack enable
corepack prepare yarn@stable --activate
yarn --version
```
## Configuration
Yarn V3 doesn't support global options and instead has project (dir) specific options which write for any non-defaults a new .yarnrc.yml file in your current dir.
This is similar to python packaging (pip and venvs) and is preferable for working with projects.
In any case check out the [sample config for this gitea, it will be kept updated.](./yarnrc.yml).
## Tip
Yarn V1 renaming a package:
```json
{
"dependencies": {
"some-package": "npm:@scope/some-package"
}
}
```
Yarn V2/3 doing the same:
```json
{
"dependencies": {
"some-package": "npm:@scope/some-package@<version statement>"
}
}
```
The range is necessary for installing the package.