'expo' not recognized as an internal or external command - npm

I installed expo-cli using npm but after the successful installation, when i try to run expo --version, it shows that expo in nor recognized. I tried adding path to the environment variables but that doesn't seem to work. I have to start working on React Native. Are there any go throughs to this issue?

There is more than one solution to get
'expo' is not recognized as an internal or external command,
operable program or batch file.
Solution 1
Make sure you have installed it global
For npm
npm install -g expo-cli
For Yarn
yarn add -g expo-cli
Solution 2
Make Sure you have added
%USERPROFILE%\AppData\Roaming\npm
to your environmental Variable. I already faced this issue and solved by adding above to my environmental Variable
Solution 3
I don't know how to category this solution, Try to run
npm cache clear -f
in your terminal and
npm install -g expo-cli

Related

RN Expo issue - Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app

I am using react native and Expo. I am unable to build new app because after I use expo init appName it shows the following error.
Heres the full message:
📦 Using npm to install packages. You can pass --yarn to use Yarn instead.
√ Downloaded and extracted project files.
× Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd Scanner
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
I tried multiple times to create a blank project, also tried npm install to install failed/not downloaded libraries and continue after failure but it showed another error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
also tried npm cache verify that showed cache is ok Content verified: 3562 (252580364 bytes).
So, How can I solve this issue?
Problems related to npm installation are very common If you do any mistake in early installation, but is avoided. Learn more about npm tree.
Steps worked for me are :
npm cache clean --force
npm cache verify
npm -g uninstall expo-cli --save
npm install expo-cli --global
expo init app-name
cd app-name
npm start
Always run as administrator if working on Windows and in root directory.
The solutions above didn't work for me but if you use 'npm install' in the directory of the app you get a clue that you shuold try 'npm install --force'
err message
You should have all these files folders and files at the start of the project otherwise not all the dependencies have been installed which is why we were getting the problem.folder structure
After you have added --force to npm install you have all the dependencies installed. Now you can run the app with npm start.
Unfortunately, all the solutions described above didn't work on my machine...
Here is my latest solution for this problem...
This worked 100% on my machine...
Use npm i -g expo-cli
This will automatically add the required packages and also remove the unnecessary ones.
Yes, surely, you don't need to uninstall and re-install it again.
Just follow my steps.
And, you can create your expo project using expo init.
I hope my solution will help you out from this annoying problem....
I just did npm install and it worked for me, but I had do that every time I create a new expo project.
I also encountered this problem, and finally found that it was the problem of react native cli,I installed the latest version of react native cli,Expo is back to normal
This Error is regarding to the git account. expos need a git account to setup react native project
If you are using windows you need to install git in your local PC
after that open your Terminal and type this command
git config --global user.name "your_username"
git config --global user.email "your_email_address#example.com"
after that clone any github project to your local computer. it will ask to login to Github
after all these steps try expo init <projectname>
The simple way to settle that error is by using "expo-cli init app-name" instead of "expo init app-name".
I tried and worked perfectly for me. Hope it will help you guys.
i have faced a similar problem and running yarn set version 1.22.1 fix it
Run the Command Prompt as an administrator. And run the following command:
npx create-expo-app AwesomeProject

How to solve 'vue-cli-service' is not recognized as an internal or external command?

I am getting an error when trying to run npm run serve. At first I installed node.js then vue as well as vue/cli.
But when I am trying to run server as -> npm run serve at that time I'm getting error like 'vue-cli-service' is not recognized as an internal or external command.
I used below codes for installation:
npm install -g vue
npm install -g #vue/cli
can someone guide me what to do to solve this issue ?
I think you are using cmd in windows.
Try deleting the node_modules folder and after that run npm i from the cmd.
Then try running npm run serve again and see if it works this time
Install vue/cli-service globally
npm install #vue/cli-service -g
This will install global npm package.
#vue/cli-service is usully installed as global, because you do not usually copy these types of packages to every project.
If the global npm package gets corrupted, it is not stored in node_modules folder, but rather in other depending on the os. Therefore removing node_modules does not help. Locations for global node_modules folders are
%USERPROFILE%\AppData\Roaming\npm\node_modules (Win10) or
/usr/local/lib/node_modules (Linux),
check this stack overflow post on how to locate global packages.
it will depend on the package manager you are using
delete node_modules
if you are using yarn run yarn or yarn install and then yarn serve
if you are using npm run npm install and then npm run serve
In my case, the package #vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type .\node_modules\.bin\vue-cli-service serve and it works.
As it is mentioned in terminal that node_modules is missing from your project, so you can't directly use npm run serve, first you have to do npm install then do npm run serve. It will work fine
In my case I ran below commands in GitBash and it worked fine
npm install
npm run serve
If you are using cmd in windows.
deleting the node_modules folder and after that run npm istall from
the cmd.
run npm run serve and see if it works this time
In my case, I have checked the folder of node_modules was missing. I am using Windows. So I run this in cmd.
npm install
npm run serve
Then I check it in localhost like usual.
This issue mostly happens when either #vue/cli is not installed or in most cases,
#vue/cli is already installed and you are currently working on a project and when running
yarn serve or npm run serve.
Most at times, this issue is been caused by broken dependencies.
to fix this issue, simple run
yarn install or npm install
depending on your package manager.
well after trying all the solutions above and it still haven't worked for you then you probably have a stupid space in the full directory of your Vue project like in my case. so remove that that space and it will work from then on.
Remember to set the NODE_ENV=development and run npm install again
Try changing the project path to one without spaces, it worked on windows 10
I had faced the same problem in windows. Then
first I deleted the node_module. then I run npm install.
For Windows you should modify package.json to:
"scripts": {
"serve": "vue-cli-service.cmd serve",
"build": "vue-cli-service.cmd build",
"lint": "vue-cli-service.cmd lint"
}
,
I had the same issue using windows + WSL2 (Ubuntu 20.04). Looking at the logs generated after trying to run npm i I noticed that my WSL2 environment did not have python2 installed. So to solve I ran the following commands:
sudo apt-get install python2
rm -rf node_modules
npm i
npm run serve
I faced the same in Windows. Had to run npm install again. Then it worked perfectly.
Wait, what's the difference between #vue/cli and #vue/cli-service? When you install both, they show different number of packages installed. The latter solved my issue actually but everyone keeps saying install #vue/cli.
try running npm i or npm install and then proceed to run npm i vue after previous installation done. works for me
you need use "npm install" at Command Line
Before running "npm install", try running this command first:
npm set strict-ssl false
Like you, I got the error below when I ran npm run serve from the CMD command line,
'vue-cli-service' is not recognized as an internal or external
command, operable program or batch file.
I got past this familiar error by using the following command to add the npm folder to the PATH that CMD searches for executables:
path=%path%;C:\Users\<USERNAME>\AppData\Roaming\npm
where <USERNAME> is your Windows user profile directory name. Only then was I able to run the following commands successfully:
npm install
npm run serve
What solved the issue for me was renaming the directory. I had used the symbol "&" on the folder name and it seems to break things, so changing it to "and" fixed the issue.
This will probably be an incredibly niche thing, but if I help even 1 person it's fine by me.
I have a project, I can run it well on Linux, but i have the same issue on windows, I solve it this way (I hope in your case it works too):
Delete the node_modules
Install it again with npm i

npm install -g not working while uninstalling react-native-cli?

I am trying to uninstall the "react-native-cli" which I use for react-native projects! but I am not able to do so!
My environment is mac.
Here is what i have done so far!
Whether I type npm uninstall -g react-native-cli or sudo npm uninstall -g react-native-cli.
The terminal shows: up to date in 0.041s
When I type react-native init projectName, it still creates the project.
I think the command react-native init should not to work.
Anyone knows how to uninstall react-native-cli ?
Thanks in advance.
SOLUTION ONE !
not fully sure this will work! but try updating your npm first by doing
npm install npm
and after that try uninstalling the cli if that does not work then
SOLUTION TWO !
Here is another go around to solve the issue its a bit manual way
1: First run this
npm list -g
this will show the list of installed packages in your user folder
then check . using command+f if there is react-native-cil there
then do this
open /usr/local/lib/node_modules
This will open the root installed packages and you can manually find and delete the react-native-cli like this
If you are using yarn. You can do yarn global list then check that if any package contains react-native. Then run yarn global remove <package> to remove that package.
ex:
yarn global remove #react-native-community/cli
You can uninstall react native CLI using:
npm uninstall -g react-native-cli

Problems while setting up vue-cli

I'm trying to install Vue-cli environemnt via NPM.
npm install --global vue-cli
After that I want to create project
vue init webpack my-project
And I get an error
'vue' is not recognized as an internal or external command,
operable program or batch file.
I've read some solutions, most of them concern changing
PATH to C:\Users{YourUser}\AppData\Roaming\npm
Didn't work for me. Can anyone help.
I follow these commands, It's work fine for me.
npm install -g vue-cli
npm install -g vue
Edit the System environment variables, and enter the following path, and if still having a problem just try to add a path in System User Variables
C:\Program Files\nodejs\node.exe;
C:\Users\{UserName}\AppData\Roaming\npm
Check vue installed in C:\Users{UserName}\AppData\Roaming\npm
yarn add #vue/cli-service
or
npm install #vue/cli-service
is what worked for me
Well, problem was solved by simply deleting everything related to vue-cli installed before. And re-installing vue-cli.
I have faced simillar issue and re-installing vue-cli didn't work for me. Strange thing is vue and vue-cli get installed successfully but once I tried to create project by using below command
vue init webpack myfirstproject
I get below error:
'vue' is not recognized as an internal or external command,operable program or batch file.
Tried various solutions but nothing worked for me. Please find my NPM and Node details below:
NPM version: 6.2.0
Node version: 8.7.0
Actually the issue was "vue-cli" is not supporting to my Node(8.7.0). It requires Node >=8.9. Once I upgraded my Node version. everything is working fine.
upgrading your Node version is the correct way to deal with this issue
I found this same issue with another possible problem. I had
create-react-app#1.5.2 installed globally
npm list -g --depth=0 will display your globals
I simply uninstalled create-react-app
npm uninstall create-react-app
Vue vue-cli-service now works as expected.
had the same issue, i deleted my node_modules and re-install and it worked
I had the same problem after searching a lot I found this solution:
You need to Add C:\Program Files\nodejs to your PATH environment variable. To do this follow these steps:
Use the global Search to go to "Environment Variables"
Click "Edit system environment variables"
Click "Environment Variables" in the dialog
In the "System Variables" box, search for Path and edit it to include C:\Program Files\nodejs.
You will have to restart any currently-opened command prompts before it will take effect.
I hope it works, good luck!
I was installing #vue/cli using yarn, i.e. I ran
yarn global add #vue/cli
Calling vue on windows did not work after the installation ('vue' is not recognized as an internal or external command)
What I needed to do was to add C:\Users\<MY USERNAME>\AppData\Local\Yarn\bin to path.
yarn global add #vue/cli did not work for me
So I removed using yarn global remove #vue/cli
Then I installed using npm install -g #vue/cli and its working fine.
1)Try to remove all the node files, npm and nvm files/folders.
2)Also, remove the PATH of node js and nvm from environment variables.
3)try commands:
node -v
npm -v
nvm -v
above commands only to make sure that all the entities related to node are uninstalled.
4) install node, and if necessary install nvm(optioal), then run command
npm install -g #vue/cli
above procedure proven to be useful for me. Just give it a try!
for Yarn -> need to install it:
npm install -g yarn
Installing Vue CLI Package:
yarn global add #vue/cli
To create project:
vue create project-name
To run:
yarn serve
Uninstalling:
yarn global remove #vue/cli
I follow "npm" package manager instead of "yarn" package manager console because yarn give me a problem while installing it;
command to install Vue CLI:
npm install -g #vue/cli
For to create Vue project:
vue create "project-name"
For to run Vue project:
npm run serve

'react-native' is not recognized as an internal or external command, operable program or batch file

I recently started with react-native. I install it using the tutorial on the Facebook site and everything works well for a day or two until this message comes up:
'react-native' is not recognized as an internal or external command,
operable program or batch file.
Nothing works except uninstalling everything and starting all over again. The environments are ok and work (npm, choco, etc.). I have also tried removing and adding react-native to environment variables, restarting, and running cmd in administrator mode, but nothing so far. I should add that I use windows 10 64-bit.
I had the same issue and tried the following but didnt work
Adding npm path to my Environment variables; both system and user
Re install npm and react-native-cli
Both didn't work for me, im using Windows 10;
Solution that worked for me is to install react-native-cli globally
You can install it globally by using the below command:
npm install -g react-native-cli
You can simply use npx react-native <command> it will work
npm install -g react-native-cli
But dont forget to restart command promprt
Your system or user environment PATH variable was edited, you can uninstall NodeJs and install it again or add the below path to the end of PATH variable into user variables the restart the Windows :
C:\Users\[USER-NAME]\AppData\Roaming\npm
this should work.
You need to setup the npm path in your environment variables. Please look at the images down below
Then follow the command : for installing -g ( global ) for cli in your system
npm install -g react-native-cli
I get the same error right off the bat on Windows 10 running in cmd window in adminstrator mode, however there is also a bash shell version of react-native that worked for me in a git bash window.
cmd:----------------------------------------------
C:\Users\David\Documents\react>where react-native
C:\Users\David\AppData\Roaming\npm\react-native
C:\Users\David\AppData\Roaming\npm\react-native.cmd
C:\Users\David\Documents\react>react-native init AwesomeProject
'react-native' is not recognized as an internal or external command,
operable program or batch file.
git bash:----------------------------------------
David#CYBER-PC ~/Documents/react
$ react-native init AwesomeProject
This will walk you through creating a new React Native project in c:\Users\David\Documents\react\AwesomeProject
Installing react-native package from npm...
Setting up new React Native app in c:\Users\David\Documents\react\AwesomeProject
AwesomeProject#0.0.1 c:\Users\David\Documents\react\AwesomeProject`-- react#15.3.1
To run your app on iOS:
cd c:\Users\David\Documents\react\AwesomeProject
react-native run-ios
- or -
Open c:\Users\David\Documents\react\AwesomeProject\ios\AwesomeProject.xcodeproj in Xcode
Hit the Run button
To run your app on Android:
Have an Android emulator running (quickest way to get started), or a device connected
cd c:\Users\David\Documents\react\AwesomeProject
react-native run-android
npm install -g react-native-cli
I had to add the %APPDATA%\npm folder to my PATH on Windows 10. Global modules are installed there.
If uninstalling and installing again the npm did not work on you, try adding %APPDATA%\npm to path (Environment variables) then quick reboot/restart. System Reboot should really be part of the process. This worked on my end.
Install :
npm install -g react-native-cli
Uninstall :
npm uninstall -g react-native-cli
If you are following the getting started guide for Windows/Android, they recommend installing nodejs via Chocolatey. But Chocolatey likes to have administrator rights when it installs things. If you're just a regular user, this seems to interfere with how npm installs react-native-cli. In my case, the react-native command was only recognized when I launched a command prompt as admin.
What I did to fix:
launched command prompt as admin
uninstalled react-native-cli globally: npm uninstall -g react-native-cli
uninstalled nodejs via Chocolatey: choco uninstall nodejs
Now, as a regular user without admin rights:
installed nodejs via the nodejs website (not Chocolatey)
installed react-native-cli globally: npm install -g react-native-cli
I uninstalled node.js and then reinstalled it, and it worked like a charm
just uninstall the node.js and reinstall it..
then install the cli package typing command
npm install -g react-native-cli..
now you are ready to make your project.
To make project open a folder from your drive wherever your folder is located.
Then type command
react-native init albums
it will create a project for you inside your directory.
None of the above mentioned solutions worked for me. What did work was to remove nodejs, and reinstall it via Chocolatey with the following command:
PS > choco install -y nodejs.install python2 jdk8
> npm install -g react-native-cli
C:\Users\user\AppData\Roaming\npm\react-native ->
C:\Users\user\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli#2.0.1
added 41 packages from 15 contributors in 4.528s
I had this problem also becuase I restored my files from a previous OS installation. My problem was a wrong prefix in my C:\Users\user_name\.npmrc file.
Run npm config list and make sure that all your npm config variables are leading to the correct file paths. Delete the .npmrc file if you want have it to go back to the defaults. That's what I did and react-native command is working for me again.
I hope this helps.
i have no clear idea but below steps worked for me.
delete Node Modules
Uninstall react-native cli. This is Recommended in the react-native Documentation
"If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues."
npm uninstall -g react-native-cli
clean gradlew. in your project folder, go to the android folder by typing cd android
and run gradlew clean
move back to your project folder cd .., then run
npx react-native run-android
these steps worked for me. took some time when running first time.
use node.js stable version or recommended version.
On window 10, nodejs>11 global node libraries seems to be installed in C:\Users\your_user_name.npm-global. So you need to set the variable to point to that path
I had problems because of this strange mistake.
I checked to see if it was globally loaded again
I didn't delete all packages
I even deleted C:\Users[USER-NAME]\AppData\Roaming\ npm manually, but there was no solution.
The only thing that is the solution is to use the current version of node.js.
uninstall nodejs completely(restart your pc) and reinstall it using chocolatey and follow other commands from https://facebook.github.io/react-native/docs/getting-started.
worked perfectly fine for me!
Even if you have installed react-native globally and still get the same try adding path of npm module (C:\Users\your user name\AppData\Roaming\npm) to system variables instead of user variables.
I know it's too late, anyway
Make sure you've added the path of the NPM in system variable rather than user variable in the System Environment Variables.
PATH : C:\Users\user_name\AppData\Roaming\npm
Open a the command prompt and type: npm config list:
Get the path underlined in red and add it your system path (change two back slashes into one), for example: C:\Users\YOURNAME\AppData\Roaming\npm.
This solved the issue for me
I just wrote "react-native -v" to console to check have I still react-native and then just I wrote "react-native run-android" again and this time it worked. Yes just that. React native is terrible technology.
Looks like I have uninstalled react native cli by mistake, I tried all answers mentioned above, but the below command worked for me.
npx react-native run-android.
Solution
I was facing 'react-native' is not recognized as an internal or external command,operable program or batch file error when I was running react-native start in VsCode.
I Solved it by running npm install -g react-native-cli in PowerShell
Steps to follow
run PowerShell as admin (important step)
run running npm install -g react-native-cli in PowerShell
close VsCode and rerun it
that's all!
I solve this problem by running
npm install -g react-native-cli
then another error appears
Command run-android unrecognized.
I fixed this error by
npm install
Use npx before your command
npx react-native
Not just
react-native
if you faced the same issue as me just type :
npm i react-native
then try to create a new project as its recommended by the react native doc by typing :
npx react-native init yourProjectName
this should resolve your problem
hope this was helpful