Git Bash Command on Windows, yarn command not found - node.js

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

Related

Error: You need to specify a command before moving on. Use '--help' to view the available commands [duplicate]

Running windows 7 Professional 32bit.
I tried running npm install -g angular-cli both under normal or admin.
I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also.
What am i doing wrong?
I solved this problem in accordance with the figure:
run in cmd
npm install -g #angular/cli
and then
( open in Windows 10) Control Panel\All Control Panel Items\System
or accordance with the figure
step 1:
step 2 :
step3:
step4:
step5: add missing ng path
Here is new environment variable that you need add: C:\Users\PK\AppData\Roaming\npm\node_modules\#angular\cli\bin
Finally, restart all opened command prompts and try again.
For me it works with:
npm run ng <command>
Adding C:\Users\DELL\AppData\Roaming\npm to System Variable Path worked for me. Please find your appropriate file path to 'npm'
Also, check if you have added your angular-cli\bin path to the path variable.
I am using WIN 10, just figure it out for this problem.
Type the code below in cmd:
npm config get prefix
and copy&paste the path that you get it from the top into your computer environment variables-->user variables box --> path --> edit -- C:\Program Files\nodejs\node_global, your path may different.
Click Ok and reopen your cmd window, type in ng version, then it works! Cheers!
Just open your command prompt (run as administrator). Ensure node --v is 6.9.0 or higher and npm --v is 3.0.0 r higher.
After that run the following command:
npm install -g #angular/cli
Once angular is installed. you can see an entry of angular cli in the path
C:\Users\Dell\AppData\Roaming\npm\node_modules\#angular
Then try ng help. It will work.
1) Enter below command on command prompt
npm install -g #angular/cli
2) Make sure that C:\Users\_username_\AppData\Roaming\npm this path is not hidden.
3) Add C:\Users\_username_\AppData\Roaming\npm and
C:\Users\_username_\AppData\Roaming\npm \node_modules#angular\cli\bin to both enviroment variable path.
4) Open new command prompt and type ng help. It will work.
With a command
npm install -g #angular/cli#latest
It works fine, I am able to run ng command now.
I solved it few days ago, after having the same problem with other global modules, by adding to:
Environment Tables -> System variables -> Path:
C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin;C:\Program Files\MongoDB\Server\3.2\bin
Note that it must not have any spaces after ;
That turned out to be my problem.
I followed below steps for resolution for this issue in Windows 10:
First make sure you have installed Angular CLI . You can use below
to install same.
npm install -g #angular/cli#latest
Make sure that AppData is visible and navigate to path below.
C:\Users\rkota\AppData\Roaming\npm
Same path can be found by running below too:
npm config get prefix
Add the above path i.e. " C:\Users\rkota\AppData\Roaming\npm" in Environment variable PATH and make sure it got added by running path in command prompt.
Close command prompt and now try to run below:
ng --version
you will be able to see CLI version.
execute following lines in order to solve the issue for both not found and undefined version of ng
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm cache clean
npm install -g #angular/cli#latest
Instead of using the in-built command prompt better start using the NodeJS installed version of command prompt. Then it is going to work perfectly without any issues.
General problem is that OS tries to find the PATH variable with ng keyword and cannot find it.
For me, even after the steps #behrouzmoslem suggested in the top answers to this post I didn't manage to get it work, because after the launch of ng command OS started to respond, but opens up editor file by the path C:\Users\{username}\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng which is actually funny. So, solution is:
Just use npx before any angular executables.
Eg : npx ng serve for serving the angular app or npx ng build --watch to build with watcher.
If you get the error even after following the above step. then try below.
Since it is a node script. I am using the below option to create as of now.
node C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng version
May be symbolic links are required. Not researched further.
On Further Research:
Set Path as : %PATH%;C:\Users\Administrator\AppData\Roaming\npm;
In Windows, npm.cmd file is in the above path. If the above Environment variable is set, you can execute as
ng version
ng init
Open cmd and type npm install -g #angular/cli
In environment variables, add either in the user variable or System variable "Path" value=C:\Users\your-user\.npm-packages\node_modules\.bin
In cmd: c:\>cd your-new-project-path
...\project-path\> ng new my-app
or ng all-ng-commands
I resolved by adding - %AppData%\npm\node_modules#angular\cli\bin\ path to my environment variables path
close cmd and open it again with admin right or reboot ur system.
for me it works only with the flag --force:
npm install -g #angular/cli --force
If everything is fine then you shoud see the folder node_modules in this path:
C:\Users\YOUR_USERNAME\AppData\Roaming\npm\
I faced same issue when i tried to install angular cli locally with command
npm install #angular/cli#latest
After that i got same issue
C:\Users\vi1kumar\Desktop\tus\ANGULAR\AngularForms>ng -v
'ng' is not recognized as an internal or external command,
operable program or batch file
Than i tried to install it globally
npm install -g #angular/cli#latest
In this case it worked I was wondering that is it not possible to install cli globally ?
After doing some research I found this article very helpful hope it will help someone facing similar issue
Working with multiple versions of Angular CLI
This one almost worked for me, but I had to use: %USERPROFILE%\AppData\Roaming\npm
. In Environment Variables.../System variables/Path
Then when I did CMD: "ng -v" I got the correct response for angular cli.
npm install -g #angular/cli helped for me instead of npm install #angular/cli
1- Install
$ npm install -g #angular/cli
2- Make sure where your ng.cmd is present.
3- Then add this path into variables.
I had the same problem on Windows 7, 64 bits running with npm v3.10.8.
I added the path as it was suggested: ( C:\Users.....(your user name)\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) and uninstalled angular-cli.
After this, I cleared the npm cache by npm cache clean as prompted here https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/. This guarantees there are no leftovers.
Reinstalled angular-cli with npm install -g angular-cliand voila.
Hope that may be useful!
In my case I did below steps.
All Programs -> Node JS-> Right click on Node.js Command Prompt and select properties and from Target string at end copy below
/k "C:\Program Files\nodejs\nodevars.bat"
I launched Visual Studio Code and opened below file
C:\Users\gochinta\AppData\Roaming\Code\User\settings.json and gave below
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shellArgs.windows":
["/k", "C:\\Program Files\\nodejs\\nodevars.bat"]
}
Now I typed ng -v in my Visual Studio Code Terminal window and it worked.
I was having the same issue when tried with the syntax "ng new " and solved that simply by updating the existing node version from 5.x.x to 8.x.x. After successful updation of node, the syntax worked perfectly for me. Please update the existing version of node. As it is clearly mentioned in angular documentation that these commands require the node version >= 6.9.x. For reference please check https://angular.io/guide/quickstart. It clearly states "Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine".
I faced same issue on x86, windows 7;
uninstalled #angular/cli
re-installed #angular/cli
checked & verified environmental variables (no problems there)...
Still same issue:
Solution was the .npmrc file at C:\Users{USERNAME}... change the prefix so that it reads "prefix=${APPDATA}\npm"... Thanks to this website for help in resolving it
For me something was wrong in the PATH enviroment variable. I removed all path related to npm and added at the start of PATH this folder:
c:\Users\<your-user-name>\AppData\Roaming\npm\
Make sure you have ; between paths.
I am facing same issue and it's get resolved. At my end reason is i install node and CLI using other user profile and now i am running ng command from other user login. Since node and cli installed using other user login node is not finding anything on C:\Users\<user name>\AppData\Roaming this path and that's why i am getting this error.
I run npm install -g #angular/cli command and restart my machine. Every thing is working fine.
Sometime in the future. Applicable to Windows 8.1 machine.
Run the following commands
npm install -g #angular/cli
Log out or restart your machine.
This should add the required env path, rather than doing it manually.
I also tried to play with cmd by setting environment variable path & etc, but simple answer is use nodejs command prompt.
So you no need to set environment variable path or anything. When you insalled nodejs it will give it's command prompt, by using that you us "ng" command, without any settings.
Since this question is still asked over and over again one year later I will post my answer here as well.
The clue (on Windows only) is to arrange the entries in the path variable right.
As the NPM wiki tells us:
Because the installer puts C:\Program Files (x86)\nodejs before C:\Users\\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm#<version>.
So your path variable will look something like:
…;C:\<path-to-node-installation>;%appdata%\npm;…
Now you have two possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with the installed Angular CLI version.
If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this: …;C:\Users\<username>\AppData\Roaming\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or …;%appdata%\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.
This worked for me since a while now.

Npm not working (openSSL configuration error windows10x64)

I was getting this error whenever I try the npm command in powershell:
**~ $ node -v
v17.1.0
~ $ npm -v
OpenSSL configuration error:
74240000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
74240000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
74240000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:
OpenSSL configuration error:
A8250000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
A8250000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
A8250000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:**
Another thing I noticed is that the node must have updated incorrectly because even though it gives me a version, I cannot uninstall it and cannot find the install files in my program files. I am at a total loss and about to just reset my computer to default. I want to repair it but everything online tells me to use npm, which in itself is not possible.
I have tried using the "set OpenSSL" command to empty or to a dummy file but it does not seem to do anything.
Go to the Windows control panel and click on Uninstall a program, select Node.js and click on the uninstall tab to uninstall the node and npm successfully. Restart your system.
Then go to https://nodejs.org/en/ to download 16.13.0 LTS version and install it
Please check environment path using PowerShell
check environment path:
cmd /c echo %PATH%' or 'cmd /c echo %OPENSSL_CONF%
You will get C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf path so reset the environment path for openssl using below comment on PowerShell
set OPENSSL_CONF=''
after that, the problem will be fixed.
this issue already issued on Nodejs GitHub.
https://github.com/nodejs/node/issues/40547
the only thing that you're to do is to create a new archive called openssl.cnf
in this route:
C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf
Save the work and run in cmd: npm --version
Had this issue in a conda environment. Fixed by installing node with next command: conda install -c conda-forge nodejs=16.3.2
Try to uninstall the node from your project directory.
npm uninstall node
Most probably you have 2 different versions of Node installed on your system.
If my solution does not work for you. Try the other suggestions with uninstalling Node from the system.
My solution was to use another node version in this case 15.8.0, you can try with others most recently versions. When I did this npm was installed correctly:

NPM not found when using NVM

I have installed node/npm using the nvm documentation.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
Then:
nvm install node
At this point node is working but the npm command result with:
npm: command not found
How can I have npm to work correctly ?
I found out that this was a conflict with a previous versions of npm that have not been removed properly despite a apt-get remove node.
I solved it by reinstalling npm from scratch:
rm -R ~/.npm ~/.nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
nvm install node
I found the solution here.
If you run NVM-Windows, don't forget to run nvm on. (this solve the problem as title for me.)
I fixed this by doing this command:
$ command -v npm
and then reopen the shell window.
I solved it by uninstalling all problematic node versions (e.g. v14 below) and reinstalling it.
The problem:
node --version; npm --version;
v14.17.1
Command 'npm' not found, but can be installed with:
sudo apt install npm
The solution:
nvm deactivate
echo "All versions BEFORE:"
nvm_ls
# uninstall all 14.* versions
for v in $(nvm_ls 14); do nvm uninstall $v; done
echo "All versions AFTER:"
nvm_ls
# reinstall version 14
nvm install 14
# and now it has npm too
node --version; npm --version
which node; which npm
# v14.17.1
# 6.14.13
# /home/user/.nvm/versions/node/v14.17.1/bin/node
# /home/user/.nvm/versions/node/v14.17.1/bin/npm
If you use Windows OS, make sure you removed the existing nodejs and npm.
In my case, it worked well after I remove the C:/Program Files/nodejs.
Reference is here.
During nvm installation, make sure the selected path must NOT exist.
This problem especially happens in windows which happens because of missing admin rights for cmd.
If you are using Git bash
Go in installation directory e.g C:\Program Files\Git
Right click properties -> compatibility.
Tick the checkbox with label -> Run as administrator.
Run the git bash again & execute npm list and then npm use 'version_to_be_used'
Same goes for Cmd
One possible reason is the NVM symlink is invalid.
But first, check if both NVM_HOME & NVM_SYMLINK is already set in environment path.
If not, maybe some problem with your nvm installation and u might want to reinstall.
Using explorer, open the symlink folder to check if the folder is valid.Default Symlink path in Windows: C:\Program Files\nodejs. Symlink appears as a normal shortcut in Windows explorer.
If you see node files in there, then you're fine.
If the folder is invalid, delete the symlink.
Then, execute nvm ls and nvm use <desired node version>, this step will re-create the correct symlink.
Restart CMD and test nvm current, node -v, npm -v
For Windows:
nvm creating symlink from installed node path like c:\program files\node to the c:\users<your user>\AppData\nvm<node ver>
So check:
Your basic node path in the PATH variable.
Your npm is inside c:\users<your user>\AppData\nvm<node ver>\nmp and this path is also int the PATH variable.
You could also run
source ~/.bashrc
and try to run again on the same bash terminal where you downloaded the install.sh the command:
npm -v
I went through a similar issue recently and solved it by setting the npm mirror to npm_mirror https://github.com/npm/cli/archive/refs/tags/
The default npm mirror (https://github.com/npm/cli/archive) was a broken link.
so run
nvm npm_mirror https://github.com/npm/cli/archive/refs/tags/
I had the same issue while any new terminal instance started up the message 'npm not found' was shown. I noticed that I had defined (probably) custom paths to npm and node in ~/.bashrc. Deleting them (keeping the paths for nvm) resolved the problem.
This helped me: https://github.com/coreybutler/nvm-windows/issues/548#issuecomment-768297716 Adding quotes to NVM_SYMLINK environment variable: "C:\Program Files\nodejs" instead of C:\Program Files\nodejs.
Install node using node source distribution:
curl -sL https://deb.nodesource.com/setup_[version].x | bash -
apt-get install -y nodejs
[version] = the wanted version. See the repository to choose the correct: NodeSource Node.js Binary Distributions

Nodejs Meanio module - init Command does not work

In the process of setting up MEAN Stack,
After installing meanio module on node 0.10.26, I can not pass through the command "mean init myApp".
1. npm install -g "meanio'
2. mean init myApp
This always gives me "Prerequisite not installed: undefined".
Could you pls look at it ?
Regards
Ram
Sometimes it is neccessary to clear npm cache to make sure you really get the latest version you can use the npm cache clear command. There have been a few releases over the last few days so clearing npm cache might help you
Here is a summary of the install procedure.
sudo npm install -g meanio#latest
mean init <your app name>
cd <your app name> && npm install
grunt
Checkout http://www.mean.io/#!/docs for full documentation and make sure you meet all the prerequites.
If you are a windows user and already installed Git on your machine, first add git to path in environment variable, then try it. It should work.
I too encountered the same issue.Though I have installed GIT on my mcahine, i was getting the error
"Prerequisite not installed: GIT" while running the command "mean init myApp".
This is because your command prompt doesnt know the path of GIT exe file.
I resolved this by adding the GIT path under Environment variables as shown here http://blog.countableset.ch/2012/06/07/adding-git-to-windows-7-path/
Right-Click on My Computer
Click Advanced System Settings link from the left side column
Click Environment Variables in the bottom of the window
Then under System Variables look for the path variable and click edit
Add the path to git's bin and cmd at the end of the string like this:
;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
Please make sure that your give the correct path of GIT folder in the path under Environment variables.in your case it might not be same as mine.check where GIT files were created while installing.
Make sure you have a recent version of Git installed. That error should read, "Prerequisite not installed: git". I'll take a look at why it says undefined instead.
As user3211907 meantioned, please take a look at http://www.mean.io/#!/docs for full documentation.
Ram,
It is problem with git
install git and this problem should solve
To install git in Cent OS or any RedHat flavors use
yum install git

Building syntaxhightlighter with nodejs in windows 7

I need to build Syntaxhighlighter from here: https://github.com/alexgorbatchev/SyntaxHighlighter
I have read these:
https://npmjs.org/doc/faq.html
Getting started with NODE.JS in windows x86
Get started with Node.js in Windows
Installing node packages / dependencies using npm on Windows Server 2008
It seems that installing Nodejs from here http://nodejs.org/download/ should be enough.
Step 3 in the syntaxhighlighter Building instructions says:
3.Then ./node_modules/.bin/bower install to download dependencies
I have this path on my machine:
C:\Program Files (x86)\nodejs\node_modules\npm\bin
and I can see a bower.json in the syntaxhighlighter zip file.
I have googled how to download dependencies for windows, but I cant find anything.
There is a lot of info here:
How do I get started with Node.js
but I think this is not for windows env.
Can you assist?
EDIT:
Ok, seems to work now.
Installed Git-1.8.4-preview20130916.exe and restarted.
Step 8 ok now.
Step 9 gives "grunt not recognized".
Tried
npm install -g grunt-cli
from here: https://github.com/gruntjs/grunt/issues/774
Now I have a pkg folder
Thank you sir
Install NodeJs for Windows per instructions
Install Git for Windows, select option to Add Git to your path.
Open a new command prompt in Windows. Ideally, open as an Administrator. Do not reuse existing command prompts. The path will only be set in a new command prompt properly.
Download the code for the highlighter or use git to clone
If you got the zip file, unzip it
From the command prompt, change the active directory to be the folder of the code you cloned or unzipped
Type npm install -g grunt-cli, then Enter after each of the following...
Type npm install -g bower
Type npm install
Type bower install
Type grunt build
Done.
You have to install git package in this way:
sudo apt-get install git
It's working fine!

Resources