path variable of yarn - linux

I have installed yarn in my 16.04 LTS version according to this tutorial tutorial
have added the environment path as well, but the termial does not take any yarn commands.
on typing yarn init, it gives ::-
ERROR: [Errno 2] No such file or directory: 'init'
same for when i type yarn global bin ::-
ERROR: [Errno 2] No such file or directory: 'global'
I think it is because of the PATH variable issue, can anyone tell me what else i need to add.
Thanks

So i found the resolution to this problem . their is a package called cmdtest which was installed in my system, which also contained a package called yarn.
This yarn was conflicting with the yarnpkg, and when i was running yarn init or any other yarn commands it was probably running that yarn package with the argument, hance the error. the yarn --version and which yarn was running correctly which further convoluted the issue. i uninstalled cmdtest and installed yarn again which fixed the issue. More details about this issue can be found in this bug report

Related

React Native CLI giving error though I removed react-native-cli globally in Ubuntu 20.04

I use this command line:
npx react-native init AwesomeProject1
And find this error:
✖ Downloading template
error Error: Command failed: yarn init -y
Usage: yarn [options]
yarn: error: no such option: -y
Update:
npm uninstall --location=global yarn
this line solved my problem. Can anyone explain why this works?
Based on yarn global documentation
yarn global is a prefix used for a number of commands like add, bin, list and remove. They behave identically to their normal versions except that they use a global directory to store packages. The global command makes executables available to use on your operating system.
So you could add the install location to your system environment variable like this to use the installed packages:
export PATH="$(yarn global bin):$PATH"
Or you can do that with yarn commands like this:
First find installation location
yarn global bin
Then configure the base location with the following command
yarn config set prefix <filepath>

yarn is not recognized as a command on git bash in windows

I installed yarn using npm: npm i -g yarn
when I execute the command yarn -v or any other yarn command on cmd or PowerShell it Outputs the Version
But on GitBash it displays: C:\Users\<my_username>\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
I even tried Reinstalling Node & Yarn but it still doesn't work.
1 solution I found is that instead of yarn if I use yarn.cmd then it works in GitBash.
But I'm unable to find the reason & the correct solution for this problem. If someone has any Idea please Guide me.
I tried so many things and in the end I'm not sure which really worked. Maybe you find out that another step works in your case.
So here's some of the sensible things I did:
I reinstalled node, yarn and git because that's the default behavior of a man in confusion. (Didn't work)
Tried manipulating PATH although yarn was recognized from cmd and powershell. (Didn't work)
I found this: https://yarnpkg.com/getting-started/install. It seems like they updated the installation steps. So I tried that because it was something different from the yarn installation you and I used... It worked!
Now, if the last step was the one that worked, make sure to run npm uninstall -g yarn after

Failing to install ghost local install

When i try to install ghost using the ghost local command i keep getting the following error:
error https://registry.yarnpkg.com/gscan/-/gscan-3.5.4.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT : no such file or directory, symlink 'test/fixtures/themes/030-assets/symlink/assets/foo.png' -> '/home//.cache/yarn/v6/npm-gscan-3.5.4 -b9214433b5e866d364e4997b32b2d2c8f5a5fef7-integrity/node_modules/gscan/test/fixtures/themes/030-assets/symlink/assets/mysymlink.png'"
I've tried different versions and node versions but I always get the same error, anyone came across this before? Thanks
if you are using yarn, try this below:
yarn cache clean
yarn install --network-concurrency 1
also if you still facing the error try to delete the yarn.lock file and reinstall.

Git Bash Command on Windows, yarn command not found

I following this online tutorial on downloading and installing web files from GIT HUB. I got down to the topic: Starting Our Static Website, there I'm prompted to enter the commands to download and install the web files. However, when I enter the command yarn install, I get the following prompt: bash: yarn: command not found
How can this problem be resolved?
I'm using GIT Bash command prompt on Windows 10.
If you are using Mintty (Bash) then you simply do npm install -g yarn
You probably just did not install yarn yet.
Have a look at the yarn installation for Windows here:
https://yarnpkg.com/lang/en/docs/install/
The official Yarn setup does not tell you you need to restart your computer, but you actually have to before you can use it from your shell. So, install it from
https://yarnpkg.com/lang/en/docs/install/#windows-stable
then restart your PC and you should be able to run yarn from your console.
Working in Visual Studio Code?
Open a new terminal
Click "Terminal" → "New Terminal"
or
Simply use ctrl+shift+` (backtick)
(this backtick button is on the left of the 1 key and below Esc)
Once the Terminal is active, install Yarn by running npm install -g yarn.
Verify the installation was successful by running yarn --version.
I followed the official yarn installation for windows but is loading a page no found on github
https://github.com/yarnpkg/yarn/releases/download/v1.22.17/yarn-1.22.17.msi
so I had to the manual way which is adding the path into the environment variables
asuming you already have installed npm, if you are not sure type in the terminal npm -v
install yarn on the terminal using npm install --global yarn
check the yarn packages has been installed on
C:\Users\yourusername\AppData\Roaming\npm\node_modules\yarn
if you can see the package on your node_modules you just need to add the bin folder that is inside the yarn into your environment variables
On the Windows taskbar, right-click the Windows icon and select System.
In the Settings window, under Related Settings, click Advanced system settings.
On the Advanced tab, click Environment Variables.
Click on Edit and add C:\Users\yourusername\AppData\Roaming\npm\node_modules\yarn
Press ok save open a new terminal and try running yarn -v
What resolved this for me was repairing my Node install:
Go to Add or remove programs
Search for "Node.js"
Choose Modify
Choose Next and then Repair
After doing that I was able to run yarn without issue.
If you install yarn through MSI on windows10, and the software installed on C:\Program Files (x86)\Yarn\bin, but the path set in C:\Users\{username}\AppData\Local\Yarn\.bin, so change the path(both user and system) to C:\Program Files (x86)\Yarn\bin.
Try to type yarn.cmd on git bash, it should work fine.
for example: yarn.cmd --version.
Please check first that yarn is install or not globally
C:\Users\username\AppData\Roaming\npm\node_modules\yarn
If there is, then add this to your environment variable
C:\Users\username\AppData\Roaming\npm\node_modules\yarn\bin
Download and install yarn wizard first in order to run commands related to yarn.Click on the below link to start the download automatically:
https://yarnpkg.com/latest.msi
I could reproduce the same issue on git bash. However when i tried the same in command prompt it worked!
on bash - $ yarn add axios
bash: yarn: command not found
on command prompt -
yarn add v1.22.5
....
[1/4] Resolving packages...
It looks like there might be an issue with Yarn and certain environments. See this GitHub issue for more details.
I had same issue and for me install yarn by the installer
From the yarn official website Yarn Official website
Read through this if nothing helps:
https://bobbyhadz.com/blog/not-recognized-as-internal-or-external-command-yarn
for me i had to add environment variables as npm did not install in the "correct"/standard folder
On Windows, the output of the npm config get prefix command will look something like: C:\Users\Your_User_Name\AppData\Roaming\npm.
To update the PATH on a Windows machine, you have to:
Open the start search and type in env and then click "Edit the system environment variables"
Then click "Environment Variables"
Edit the Path variable and add the output you got from the npm config get prefix command.
The path should look like C:\Users\Your_User_Name\AppData\Roaming\npm (make sure to replace the Your_User_name placeholder with your actual username).
even tho I installed npm and yarn corect, when I check the version, the same error already appears:
393330#785-5949 MINGW64 /c/Users/393330/Desktop/intranet-app
$ npm install --global yarn
changed 1 package in 344ms
393330#785-5949 MINGW64 /c/Users/393330/Desktop/intranet-app
$ yarn --version
bash: yarn: command not foundstrong text
If you don't have npm, you can do the following (taken from yarn installation instructions):
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
Use this command on macbook
brew install yarn

How to test cli (global link) with yarn?

I am trying to test a cli (feathers-cli) that I am working on. I have cloned it's primary dependancy (feathers-generator) and made my modifications, this is what I have done.
Gone into feathers-generator (master branch) and run yarn link
Gone into feathers-cli (3.0 branch) and run yarn link "feathers-generator"
Run yarn link
created a new directory, removed my existing version of feathers-cli
Run yarn link "feathers-cli" then run yarn global add "feathers-cli"
feathers however, at this point it is using the regular version it has pulled from npm. I have looked through the yarn docs and can't seem to find anything about globally linking packages. How do I approach this?
With yarn v1.19 you can do:
yarn global add file:/fullpath/to/myproject
Yarn, unfortunately, does not seem to support this directly in any way. The best thing I've found is to symbolically link the file to the user's yarn bin folder.
On Windows: %LOCALAPPDATA%/Yarn/bin
On Linux: ~/.yarn/bin/
Easiest way is to test within a node project, even if it's a global cli tool.
Example
Say I want to test a global tool my-yarn-cli, which has a few commands new, --help, --version, etc...
In the cli tool directory, yarn link this makes the local version of my-yarn-cli available to yarn.
In an empty project use yarn link my-yarn-cli, this adds a reference to the local version of my-yarn-cli
Test out commands using yarn as a proxy, for example:
yarn my-yarn-cli --help
yarn my-yarn-cli --version
yarn my-yarn-cli new TEST_ARGUMENT
This has been a useful workflow for me, and is much better than messing with symlinks or copying directories.

Resources