Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tophat/yvm

🧢 Manage multiple versions of Yarn (deprecated)
https://github.com/tophat/yvm

deprecated es6 javascript nodejs npm opensource tophat version-manager yarn yarn-versions yvm

Last synced: about 2 months ago
JSON representation

🧢 Manage multiple versions of Yarn (deprecated)

Awesome Lists containing this project

README

        

# Yarn Version Manager (yvm) - (deprecated)

> ## ⚠️ Deprecation Notice (2022-02-20) ⚠️
>
> yvm has been deprecated in favour of [corepack](https://github.com/nodejs/corepack) which is distributed by default with NodeJS v14, and is available in older versions by installing the corepack npm package globally.
>
> With corepack, you specify your package manager and version via the `packageManager` field in your project's package.json file ([see example](https://github.com/tophat/monodeploy/blob/84dbb366ae1699adeb161e38d413c66f92cb33a3/package.json#L107)).
>
> _What does it mean to be deprecated?_ yvm will no longer receive updates (except for critical security vulnerabilities) and the repository will eventually be archived.

---

Logo

[![YVM Latest Version](https://img.shields.io/github/release/tophat/yvm.svg)](https://github.com/tophat/yvm/releases)
[![Minimum Node Version](https://img.shields.io/badge/node-%3E%3D%2010-brightgreen.svg)](https://nodejs.org)
[![Builds](https://github.com/tophat/yvm/workflows/Continuous%20Integration/badge.svg)](https://github.com/tophat/yvm/actions)
[![codecov](https://codecov.io/gh/tophat/yvm/branch/master/graph/badge.svg?token=idXHLksicU)](https://codecov.io/gh/tophat/yvm)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Dependencies](https://img.shields.io/librariesio/github/tophat/yvm)](https://libraries.io/github/tophat/yvm)
[![Dependabot](https://badgen.net/dependabot/tophat/yvm?icon=dependabot)](https://app.dependabot.com/accounts/tophat/repos/137530684)
[![All Contributors](https://img.shields.io/badge/all_contributors-27-orange.svg?style=flat-square)](#contributors-)
[![Discord](https://img.shields.io/discord/809577721751142410)](https://discord.gg/YhK3GFcZrk)
[![Maturity badge - level 3](https://img.shields.io/badge/Maturity-Level%203%20--%20Stable-green.svg)](https://github.com/tophat/getting-started/blob/master/scorecard.md)
[![Pull Reminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge)

## Overview

Pesky yarn versions got you down? Automatically and easily manage those versions.

YVM will automatically use the correct yarn version when you run any yarn commands in any folder with a `package.json`, `.yvmrc` or any other [supported configuration](https://yvm.js.org/docs/faq#declare-yvm-version-in-a-configuration-file-where-can-i-place-my-version-number) file. Otherwise, it will use you a globally set version of yarn.

## Motivation

Manually managing different yarn versions across projects is a pain. This fixes that.

## Installation

Node: >=10.0.0

### Homebrew

Installs the latest stable version.

```sh
brew install tophat/bar/yvm --without-node
```

**NOTE**: Remove the flag `--without-node` to install with the node dependency.

### Windows

[TODO: #435](https://github.com/tophat/yvm/issues/435)

### Node

Execute the following in your terminal:

```bash
curl -s https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.js | node
```

Or to install a specific version:

```bash
curl -s https://raw.githubusercontent.com/tophat/yvm/v3.2.1/scripts/install.js | INSTALL_VERSION="v3.2.1" node
```

### Script

Some older versions of yvm do not have the node installer enabled. If so the shell script installer can be used.

```bash
curl -s https://raw.githubusercontent.com/tophat/yvm/v2.4.3/scripts/install.sh | INSTALL_VERSION="v2.4.3" bash
```

### Manual

Navigate to [yvm releases](https://github.com/tophat/yvm/releases) and download the `yvm.js` file for the latest release into your desired yvm install directory.

Typically `.yvm` your home directory, then run the following command to configure your shell.

```bash
node ./home/joe_user/.yvm/yvm.js configure-shell
```

You will need to reload the shell to get yvm, or source the generated `yvm.{sh,fish}` scripts.

### Upgrade

To upgrade yvm to the lastest version either install as normal, or run

```bash
yvm update-self
```

## Usage

### Automagic

Run any yarn command and watch it automagically use the correct version of yarn.

Yarn is shimmed to use the default version or the version defined your current directory [config file](#configuration-file).

```sh
yarn --version
```

### Basic

To download and install a specific version of yarn, run:

```bash
yvm install
```

To get the latest version of Yarn, run:

```bash
yvm install latest
```

Execute an arbitrary command using a specific version of yarn:

```bash
yvm exec
```

### Additional commands

Switch the current yarn versions:

```bash
yvm use
yarn --version
```

**NOTE**: The above disables [yarn shimming](#automagic) until a new shell is loaded.

Control version aliasing:

```bash
yvm alias stable
# stable β†’ 1.13.0 (1.13.0)

yvm alias default stable
# default β†’ stable (1.13.0)

yvm alias
# default β†’ stable (1.13.0)
# latest β†’ 1.14.0 (1.14.0)
# stable β†’ 1.13.0 (1.13.0)
# system β†’ 1.13.0 (1.13.0)

yvm alias default '^1.7'
# default β†’ ^1.7 (1.14.0)
```

Show path to version used:

```bash
yvm which
```

List installed yarn versions:

```bash
yvm list
```

Full list of available commands:

```bash
yvm --help
```

### Configuration file

Yvm defaults to using the `yarn` version in your `package.json` `engines`. Otherwise you can create a `.yvmrc` file containing the version number of yarn in your project's root directory. Afterwards, `yvm use`, `yvm install` and `yvm exec` will use the version specified in the config file if no version number is supplied to the command.
You can also [declare the version using other configuration files](https://yvm.js.org/docs/faq#declare-yvm-version-in-a-configuration-file-where-can-i-place-my-version-number)

### Custom Bootstrapping

When using `yvm exec`, the appropriate `yarn` version is executed using the `node` available in the current context. This can be explicitly specified using the `YVM_BOOTSTRAP_EXEC_PATH` environment variable.

Example: if you are using `nvm`, you can avoid having to execute `nvm use` before using `yvm exec`:

```sh
export YVM_BOOTSTRAP_EXEC_PATH=~/.nvm/nvm-exec
yvm exec my-command
```

You can set this environment variable globally in your preferred shell's setup script (e.g. bashrc/zshrc).

The script referenced via the exec path must be executable. It receives the yarn executable as its first argument, and should forward the remaining arguments to yarn.

### Additional reference

A full list of commands is on the [api reference page](https://yvm.js.org/docs/api)

Have questions? [List of common questions and answers](https://yvm.js.org/docs/faq)

## Removing

To remove yvm simply execute

```bash
rm -rf $YVM_DIR
```

Next, edit `$HOME/.bashrc` and `$HOME/.zshrc` and remove those lines:

```bash
export YVM_DIR=/home/joe_user/.yvm
[ -r $YVM_DIR/yvm.sh ] && . $YVM_DIR/yvm.sh
```

Remove in `$HOME/.config/fish/config.fish` for fishers:

```fish
set -x YVM_DIR /home/joe_user/.yvm
[ -r $YVM_DIR/yvm.fish ]; and source $YVM_DIR/yvm.fish
```

In case you had older version of yvm installed, there could also be a line like

```bash
source /home/joe_user/.yvm/yvm.sh
```

or those lines could be in `$HOME/.bash_profile` instead of `$HOME/.bashrc`.

## Contributing

We welcome contributions from the community, Top Hatters and non-Top Hatters alike. Here are some guidelines to help you get started!

### Basic development flow

1. Ensure the problem you are solving [is an issue](https://github.com/tophat/yvm/issues) or you've created one
2. Clone the repo
3. We use make. `make help` will show you a list of development commands
4. `make install-watch` will install yvm on your shell and update when you make changes. Make sure to only run this in the root yvm directory, it will fail elsewhere.
5. `make test` and `make lint` are also commonly helpful

Make sure all changes are well documented. Our documentation can be found inside the `docs` section of this repo. Be sure to read it carefully and make modifications wherever necessary.
You can also access the documentation on our [website](https://yvm.js.org)

Please make sure to look over our [Code of Conduct](https://github.com/tophat/getting-started/blob/master/code-of-conduct.md) as well!

### Manual testing command contributions

```bash
make install
yvm
```

### Technologies to Familiarize Yourself with

- [NodeJS](https://github.com/nodejs/node)
- [Yarn](https://github.com/yarnpkg/yarn)

## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):



Francois Campbell

πŸ’»

Jake Bolam

πŸ“– πŸ’» πŸš‡

Brandon Baksh

πŸ’»

Milan Milojic

πŸ’»

Umar Ahmed

πŸ’»

Nicholas Dujay

πŸ’»

Aser Eldamaty

πŸ’»



Michael Rose

πŸ’»

Sanchit Gera

πŸ“–

sdcosta

πŸ“–

Siavash Mahmoudian

πŸš‡

greenkeeper[bot]

πŸš‡

Jay Crumb

πŸ“–

Michael LunΓΈe

πŸ“–



Yash Shah

πŸ’»

WacΕ‚aw Schiller

πŸ’»

yvm-bot

πŸš‡

Emmanuel Ogbizi

πŸ’» ⚠️ πŸ“–

Martin Lai

πŸ’»

Marc Cataford

πŸ’»

Ahmed Elkady

πŸ‘€



Noah

πŸ’» πŸš‡

Derek Delaney

πŸ“–

dependabot[bot]

πŸš‡

allcontributors[bot]

πŸ“–

Umar Ahmed

πŸ›

Abi Noda

πŸ“– πŸ“†

Josh Dean

πŸ“–



akeshk

πŸš‡ πŸ”§ πŸ’»

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

## Credits

Thanks to [Carol Skelly](https://github.com/iatek) for donating the github organization!