53

After running npm install -g expo-cli and successfully installing the packages globally, expo is still not recognized as an internal or external command. Does anyone know how I might get around this issue using windows 10, or what to do in terms of something like a path variable.

jf___
  • 541
  • 1
  • 4
  • 3

20 Answers20

72

Probably the only thing missing is to add the expo executable to your path.

For Windows 10, you can simply add the npm folder to your path environment variable.

  1. Hit Windows key and search for Environment variables.
  2. Inside the Path variable under System variables, add a new entry (entries are separated by semicolons) with this content (without /node_modules ):

%USERPROFILE%\AppData\Roaming\npm

OR if you are using yarn C:\Users\{USER}\AppData\Local\Yarn\bin (as @Qwerty mentioned above)

  1. Open a new command prompt and enter

> expo

You will see something like this: enter image description here

cookieman
  • 3
  • 2
Rocío García Luque
  • 3,597
  • 31
  • 31
19

I wondered it was working last night when I first installed and run the "react-native" project but the very next day it showed me the same error as yours.

Here is what I did in windows 10 Operating System:

Add the following path :

environment variable > System Variables > PATH > C:\Users\YOUR_USERNAME\AppData\Roaming\npm

Now I ran the following commands one by one in CMD:

i) npm -g uninstall expo-cli --save

ii) npm install -g expo-cli

Now start the Project and run npm start and now it works for me.

I didn't try this article one but it also shows the solution for the same problem, see here

Badri Paudel
  • 1,365
  • 18
  • 19
16

I may be too late to answer this, but for people looking for the same error this is what worked for me.

  1. Install yarn if you don't have it. I used the command choco install yarn (you'll have to install Chocolatey). If you have scoop installed, scoop install yarn also works.

  2. Use yarn to install expo with yarn global add expo-cli.

  3. expo start should work now. yarn start and npm start should also work.

Hope that helps!

Ruby
  • 413
  • 1
  • 4
  • 16
  • I have the same error and although this I haven't figured out how to solve it – Gianmarco Nov 13 '19 at 10:16
  • It might be the solution. But, setting environment variable can solve the issue so there's no need to add another package. No offence but as an efficient solution, I would consider is setting *environment variable* instead of installing `yarn` – meDeepakJain Jan 13 '20 at 11:28
9

Added These path of npm like this i have the same issue i fix it by adding the path to environment system

C:\Users\abobakr\AppData\Roaming\npm

After that close CMD and open it again it should work believe me

Abubakr Elghazawy
  • 977
  • 14
  • 21
8

go to the environment variable, then in the user variable section find Path and press the edit button, you will see a new window, press new and add the following

%USERPROFILE%\AppData\Roaming\npm

enter image description here

then press ok. Now,

expo --version
Abolfazl Roshanzamir
  • 12,730
  • 5
  • 63
  • 79
  • 4
    I am not sure why your upvotes are not skyrocketing up the roof, but thanks! But may i know why does this actually works? – Jarrett Jan 12 '21 at 03:58
5

Here is the solution I came out with.

I ran npm list -g

then copy the directory on the first line and paste in your system enviroment variables under the variable name 'path'

close all the terminals and run expo or any other command.

3

If it still doesnt work or you can't access npm. Try setting the path with the Windows PowerShell:

  1. Open Windows Powershell as Administrator
  2. Type: setx path "%path%;C:\Users\USERNAME\AppData\Roaming\npm"

It worked for me.

Manthano
  • 151
  • 7
3

This worked for me :

  1. Download latest version of nodejs - https://nodejs.org/en/download/
  2. After installing nodejs reboot your computer
  3. install : npm install --global expo-cli
  4. Generate a new project with - npx expo-cli init projectName
  5. cd projectName
  6. npm start
AB1
  • 69
  • 7
2

Re-install node.js and then run npm install -g expo-cli in command prompt.

Abhishek Kumar
  • 955
  • 11
  • 11
2

If you are using Windows 10 or 11, the solution to edit your Path variable works well. Just make sure that you replace "YOUR_USERNAME" with your username on the computer:

This means that if my username is "Green", I will replace YOUR_USERNAME here: C:\Users\YOUR_USERNAME\AppData\Roaming\npm

to

C:\Users\Green\AppData\Roaming\npm.

This article is very detailed in solving the problem in case if the above does not work for you.

AnatuGreen
  • 579
  • 7
  • 14
1

This worked for me:

  1. You must uninstall node js then install it again.
  2. You must run npm install expo-cli.

It will solve your problem

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
1

For me, i uninstalled node.js,

i re-installed node.js,

i ran npm install -g expo-cli,

then ran expo --version (the expo command began to work).

Hope this helps.

Bukunmi
  • 2,504
  • 1
  • 18
  • 15
1

If you are using yarn global add expo-cli, try npm install -g expo-cli.

I don't know why but when i go into C:\Users\%{user}%\AppData\Roaming\npm there isn't the expo package(and other packages that I thought I install globally by yarn) but there are other that I installed globally by npm.

If adding C:\Users\%{user}%\AppData\Roaming\npm to PATH variable doesn't work, give this a shot.

Joseph
  • 63
  • 1
  • 10
0

I had the same problem last night, and I've recently started my journey in ReactNative. So, there might be better answers out there.

If you're following the ReactNative Official documentation, the first time npm start works fine, the subsequent ones throws an error saying expo is not recognized. I got around that by running expo start and not npm start ( which basically is the same thing but doesn't work for some reason ).

So, mine looks like a work around rather than an explanation as to why this happens or how to permanently fix it.

Tenzin Kunkyab
  • 123
  • 1
  • 8
0

This is a more general problem where your global node modules are not in your system path. This question is what you are looking for: Nodejs cannot find installed module on Windows?

brentvatne
  • 7,603
  • 4
  • 38
  • 55
0

I have fixed this in Windows 10 by setting Path C:\Users\[USERNAME] this line save my hrs

Sohail Yasmin
  • 498
  • 5
  • 16
0

uninstall expo using this command npm -g uninstall expo-cli --save and reinstall expo using this command npm install -g expo-cli then it will work properly

viknesh
  • 61
  • 3
0

I faced same problem and it was not getting resolved by "npm install --global expo-cli". Global CLI was having error as SS below -

  • npm list -g --depth 0 Global expo-cli package issue

Followed below steps to get it resolved

  1. npm uninstall --global expo-cli
  2. Deleted global package causing error C:\Users<USERNAME>\AppData\Roaming\npm\node_modules\expo-cli
  3. npm install --global expo-cli

And expo cli worked. Happy coding!!!

0

If you need a solution to Run Expo command without Environment Variable update then on your terminal use below command for windows system:

R:\> C:\Users\{user}\AppData\Roaming\npm\expo.cmd init {projectname}

Where you directly point the expo.cmd file rather than specifying in the environment variable.

And update the expo to C:\Users{user}\AppData\Roaming\npm\expo.cmd in package.json to run the project.

// package.json
"scripts": {
    "start": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start",
    "android": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --android",
    "ios": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --ios",
    "web": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmdstart --web",
    "eject": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd eject"
  },
0

If you set the environment path as said in other replies and the command is still not recognized, try running whatever you're using to execute the command in administrator mode.

I'm using VS Code terminal and expo was not recognized until I ran it as administartor.

Few Tries
  • 23
  • 5