18

I am trying to upgrade expo-cli from 2.11 to 2.18 but npm i -g expo-cli@latest still points to the old version.

when I typed expo-cli -V it resulted:

2.11 ...so naturally npm i -g expo-cli@latest will grab the latest version and install it but still expo-cli -v is still pointing to the old version.

I remember installing packages in bash level is a no go operation.

these are some images to put it all into context: enter image description here enter image description here

Update: Removed Nodes modules as suggested in the first answer, and that lead to npm removal both expo and expo-cli are not found with the command where enter image description here

oflcad
  • 505
  • 2
  • 6
  • 19

10 Answers10

17

For mac users (linux should be very similar):

Find your expo-cli version:

which expo-cli

For me it yielded:

/Users/username/.config/yarn/global/node_modules/.bin/expo-cli

Remove this outdated version:

rm -rf /Users/username/.config/yarn/global/node_modules/.bin/expo-cli

Check that you are using the latest version:

expo-cli --version
lami
  • 1,410
  • 12
  • 16
11

Updating expo-cli globally can be a right pain. To those experiencing this frustration, use yarn

yarn global add expo-cli

it will give you far fewer headaches

eddyoc
  • 667
  • 11
  • 16
5

If you're like me, and none of this stuff worked, maybe my solution will help. My problem is that I switched from NPM, to Yarn at some point, and I had global packages in both systems, which was giving me a bunch of trouble.

Step 1: Make sure you don't have expo-cli in global npm

npm list-g

Step 2: If it is in global npm, uninstall it

npm uninstall --global expo-cli

Step 3: Install it fresh with yarn

yarn global add expo-cli

Step 4: Stop using npm for global packages (or at least, only use one system)

edit: spelling

C.T. Bell
  • 353
  • 3
  • 12
1

If you are using a Mac, these 2 commands will do the tricks 1)which expo to locate expo in your Mac which will give you this "/usr/local/bin/expo" 2) "cd /usr/local/bin/" 3)-rm expo 4)-rm expo-cli

Pascal Nitcheu
  • 667
  • 7
  • 8
  • This above tip works because you're removing *both* expo and expo-cli. No need to `cd` into the directories, though. `rm -rf /usr/local/bin/expo`, `rm -rf /usr/local/bin/expo-cli` – Design by Adrian Aug 23 '20 at 09:48
0

the hole system was behaving oddly!, npm should've been installed with node but it was nowhere to be found. I had to remove node and reinstall it again, then I had to install expo-cli again and all errors went away.

oflcad
  • 505
  • 2
  • 6
  • 19
0

When npm does not work in an easy way, --force it!

npm install -g expo-cli --force
sadiq
  • 2,238
  • 19
  • 21
0

Update to the latest version of Expo CLI: npm i -g expo-cli. expo-cli@4.7.2 or greater is required. Update to the latest version of EAS CLI if you use it: npm i -g eas-cli. Run expo upgrade in your project directory.

Reference: https://docs.expo.dev/workflow/upgrading-expo-sdk-walkthrough/

0

there is more than a reason for not updating the expo-cli.

reason 1 - you maybe installed expo-cli using yarn and after a while you need to update and using npm npm install -g expo-cli it will update but maybe when you run expo its point to that yarn version so to resolve this you need to run yarn global remove expo-cli.

reason 2 - it might you have two versions of expo-cli one its global version and one inside your project folder/path, so even you upgrade expo-cli globally, your project still point to the first class version which is in your project folder. to resolve this you need to uninstall expo-cli which exists in your project folder to point to the global version and you can do this using this command npm uninstall expo-cli notice without -g.

reson 3 - sometimes you need to clean npm cache. if nothing works for you above try to uninstall expo-cli using npm uninstall -g expo-cli and then run this command npm cache clean --force then install expo-cli again npm install -g expo-cli.

Anas
  • 1,000
  • 11
  • 18
0
  1. expo-cli --version
  2. npm uninstall expo-cli
  3. npm install -g expo-cli
  4. expo-cli --version

if cannot, you can update manually

  1. check path npm bin -g
  2. change "node_modules" folder or remove C:\Users{username}.npm-global\node_modules
  3. npm install -g expo-cli
  4. copy\past expo-cli folder from C:\Users{username}.npm-global\node_modules\expo-cli to C:\Users{username}\AppData\Roaming\npm\node_modules\expo-cli
  5. expo-cli --version
Ravshan
  • 471
  • 5
  • 2
0

You can also move from the global expo cli to the New Local expo cli

You just need to run

npx expo start

In the root of the project and it will install it if it's not already there.

Marcel
  • 88
  • 9