646947a43e
Signed-off-by: T-Hax <>
89 lines
2.7 KiB
Markdown
89 lines
2.7 KiB
Markdown
# Setting up `npm`or `yarn` v3 to work with Gitea
|
|
|
|
This is a guide to working with Gitea Tornado packages.
|
|
|
|
We can either use NPM or Yarn V3 for working with new projects. Yarn classic does not support other registries nicely. Using Yarn V3 requires more time (you have to know how to write the config), but Yarn is much more powerful and allow smoother dependency management.
|
|
|
|
The guide to installing and configuring NPM and Yarn V3 follows.
|
|
|
|
## Short `npm` solution
|
|
|
|
```bash
|
|
# Add into your .npmrc
|
|
@tornado:registry=https://development.tornadocash.community/api/packages/T-Hax/npm/
|
|
```
|
|
|
|
or
|
|
|
|
```bash
|
|
# Add into your .npmrc
|
|
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/
|
|
```
|
|
|
|
## Proper `yarn` solution (more privacy)
|
|
|
|
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).
|
|
|
|
You also need to configure the [.env](./gitea.env.example)
|
|
|
|
## Tips
|
|
|
|
### Errors
|
|
|
|
If you are installing packages and you meet `Invalid authentication (as an unknown user)` then try to comment out the AUTH token for the install process.
|
|
|
|
### Breaking changes
|
|
|
|
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. |