Zum Inhalt springen

Use yarn in cloud hosting packages

Installation of yarn using npm

Create directories

You need a directory in which your own npm packages will be installed later. If you have not yet created this, you can create it in the shell with

mkdir -p $HOME/.local/opt/npm

to create it.

Install yarn via npm

Change to the folder and install yarn via npm

cd $HOME/.local/opt/npm && npm init -y && npm i yarn

Checking the installation

Now check whether the following files/folders exist:

node_modules, package.json, package-lock.json

Execute the following command:

ls

use yarn as usual with yarn

Edit or create .bashrc file

Edit or create the following file with an editor, e.g. nano

nano $HOME/.bashrc

In most cases the file is empty. If it is, then add the following line

export PATH=$HOME/.local/opt/npm/node_modules/.bin:$PATH

Then save the file. In the nano editor you can do this with CTRL + O, ENTER and then CTRL + X to close the file.

Import change

Finally, you must import the changes. To do this, either log out and log in again or use the following command

source $HOME/.bashrc

Updated: 17.07.2024