How do I get yarn 2 to work in my project? - yarnpkg

I cd into my project and run yarn set version berry. It creates the .yarnrc.yml with the yarnPath variable. However, if I do run yarn inside the dir it still defaults to the old Yarn. I made a Makefile with commands like ./.yarn/releases/yarn-berry.cjs + install or start to get Yarn 2 to work. What am I doing wrong?

You have .yarnrc or .yarnrc.yml file in your home directory or in some of the parent folders Yarn 1 finds it and Yarn 2.x never gains control, search for it and remove.

Related

how to get automator app to run a yarn command

I'm setting up an automator run shell script to go to a specific folder on users machines and then yarn run dev but when it gets to the yarn part it can't find yarn.
-line 1: yarn: command not found
If I use terminal then yarn will run fine.
I have yarn installed -g which is in my NVM modules.
Here is my script in automator.
cd ~/Documents/myProject
yarn run dev
Also tired this setup:
Like this:
export PATH=$PATH:/Users/me/.nvm/versions/node/v10.16.3/bin
cd ~/Documents/myProject
yarn run dev
The first line tells bash where to look for programs, such as yarn and node.

Yarn (Binary) Offline installation on Centos 7

How do i install Yarn (binary) offline on Centos 7. The machine doesn't have internet. Apologise if the question has been asked before.
I couldn't find it anywhere. All Questions point to using Yarn in offline mode but not how to install it offline at the first place.
Finally, i managed to do it via tarball (Note this is Linux installation).
You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
Yarn is now in /opt/yarn-[version]/
the following steps will add Yarn to path variable and run it from anywhere.
Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.
Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to)
In the terminal, log in and log out for the changes to take effect
To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add
export PATH="$PATH:`yarn global bin`"
to your profile.
Here is the link i found it
Although Yarn can work in offline mode, the packages must be downloaded and stored in the in an offline mirror. Refer to this article.
Your Centos machine will need to be connected to another machine that has access to the Internet. The most common solution is to set up a http/https proxy, then set up yarn to use the proxy
yarn config set proxy http://proxy.server.com:8080
yarn config set https-proxy http://proxy.server.com:8080

change yarn global dir - I can not change the yarn global installation folder

Bug
yarn is not changing its global directory
The following command changes the cache directory. no problem ... thanks Yarn
yarn config set cache-folder c:\yarn\cache
But this command is not changing the global installation dir
yarn config set globa-dir c:\yarn\global
when i check after running this command:
yarn global dir
it displays:
C:\Users\admin\AppData\Local\Yarn\Data\global
Expected behavior
running the command
yarn global dir
shows c:\yarn\global instead
Environnement
Yarn 1.6.0 Node: 9.10.1 OS: win32 x64
you need to add the line --global-folder "c:\yarn\global" manually into your .yarnrc file.
Look here #5746

Yarn keeps using old registry

I've been using yarn with a private registry in the past - however, the registry has now shut down and I want to use yarn with the official registry.
Whatever I do, yarn always seems to want to connect to the old registry and there's simply no way of making it use the new one. I've already tried:
Completely remove and re-install yarn
yarn config set registry https://registry.yarnpkg.com/
Verified that there is no mention of the old registry in either ~/.npmrc or ~/.yarnrc
Cleared the yarn cache using yarn cache clean
No matter what I do, yarn still tries to connect to the old registry on every install and I have no idea where yarn is getting that from...
any ideas?
Remove your global yarn.lock
rm ~/.config/yarn/global/yarn.lock
and then
yarn config set registry https://registry.yarnpkg.com/
Got it, the culprit was ~/.config/yarn/global/yarn.lock...
Running yarn add with --verbose will tell you which .yarnrc files are being picked up. These shouldn't include the old registry.
So run yarn add <your-package> --verbose and check the .yarnrc files found for any mention of the old registry.
In my case, I got it fixed with a rm ~/.npmrc running MacOS

Where does yarn keep global packages?

How do I find the directory where yarn keeps global packages?
What are the defaults, and how do I find the value based on current configuration?
The default global directories are:
$Env:LOCALAPPDATA/yarn/config/global/node_modules on Windows
~/.config/yarn/global on OSX and non-root Linux
/usr/local/share/.config/yarn/global on Linux if logged in as root
This directory can be overridden by either npm or yarn's prefix, so to get the current value, use:
yarn global dir

Resources