Problem updating expo-cli

When I run the npm install -g expo-cli, the update completes and notes that I’m on version 3.11.1. However, when I run expo-cli -V, I see the previous version that I had–meaning that the update was not actually successful. Is there something I should be doing after updating? What is the best approach at solving this issue?

Below is a screenshot from my terminal;

I deeply appreciate any help. Thanks in advance!

are you using both npm and yarn? maybe you installed it with yarn before and yarn is first in your path. run which expo to see where the current expo-cli installation is

Thanks for chiming in notbrent–really appreciate it. Primarily, I’m using npm; however, I just installed yarn. I did the following command in terminal “yarn global add install expo-cli”. Seems like the update to the latest version of expo-cli was successful; however, when I do expo-cli -V, I still see the previous version of expo-cli.

here’s a screenshot from after installing the latest version using yarn and then checking which version of expo-cli I have.

Btw, nobrent, here’s he location for where the current expo-cli installation is when I run the “which expo” command.

What does type -a expo give you?

Also, if you want to use yarn to install expo-cli you should uninstall the copy that was installed by npm:

npm uninstall -g expo-cli

try rm /usr/local/bin/expo and then npm i -g expo-cli

Hi wodin, when I run that command. I get the following:

I’ve been using npm instead of yarn. I just recently installed yarn as I saw this to be the solution for someone’s problem on GitHub.

After following your instructions, the download seemed to work; however, when I run the command “expo-cli -V”, I still get the version that I had before. Weird that it’s still happening. Here’s the history in the terminal.

Another thing is that when I run “expo start”, it says that no such file or directory was found.

Screenshot 2019-12-18 17.51.12(2)

Also rm /usr/local/bin/expo-cli and try expo --version

It looks like your packages might be installing to /Users/xxx/.npm-global/... but the bin directory is not in your PATH. (Based on the the above screenshot and the type -a expo output.)

What does echo $PATH give you? You can just post the text here instead of a screenshot.

See if you have a symlink or file called expo in /Users/*/.npm-global/bin.

If so you might want to put that directory in your PATH before /usr/local/bin.

Just did the following command: rm /usr/local/bin/expo-cli however, when I run expo --version I get “-bash: /usr/local/bin/expo: No such file or directory”

When I run “echo $PATH”, I get the following:

/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/Ismael/.rvm/gems/ruby-2.3.0/bin:/Users/Ismael/.rvm/gems/ruby-2.3.0@global/bin:/Users/Ismael/.rvm/rubies/ruby-2.3.0/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/Ismael/.rvm/bin

OK, so the stuff unrelated to Ruby/Python/Mono is as follows:

/usr/local
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

You should not have /usr/local in your PATH but it’s also unlikely to cause problems. Also the duplicates are not going to help, but are also not going to hurt.

So that leaves basically:

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

So that confirms that /Users/*/.npm-global/bin is not in your PATH. I am pretty sure based on the screenshot from your second last message that that is where expo-cli is being installed. Please confirm that.

The -bash: /usr/local/bin/expo: No such file or directory error is because your current bash session still thinks that is where the expo command exists, for two reasons:

  1. It keeps a cache of paths to commands that it has encountered. You can clear this with hash -d expo
  2. The PATH doesn’t contain the location that your npm command has installed the new version, so bash can’t find it.

To clarify, because I’m quite new to this, how do I put the directory in my PATH before /user/local/bin ?

Thank you!

Thank you so much for helping here, I much appreciate it.

When I do ls /users/*/.npm-global/bin I see folders for expo and expo-cli. From your assertion, that seems to be where expo-cli is being installed.

Unfortunately this is not as straightforward as it should be :stuck_out_tongue:

But the easiest is probably:

Edit a file in your home directory called .profile
Add the following line at the end and save and close the file:

export PATH=~/.npm-global/bin:$PATH

Then close your Terminal window and open a new one.
To confirm that the PATH has been updated, echo $PATH again.

Hey wodin–thanks again for your continued support. I added the export PATH=~/.npm-global/bin:$PATH to the end of the .profile in my home directory. Here’s a screenshot:

I saved it and did the echo $PATH command and here is the output:

Hi

You need to close your terminal window and open a new one for bash (running within the new terminal window) to re-read your .profile.

Gotcha, I just saved the export PATH=~/.npm-global/bin:$PATH in .profile. I opened a new terminal window and did echo $PATH. Here’s the output from the new terminal.

OK, that’s weird. I don’t know what exactly is going wrong there and debugging by proxy is getting a bit hard :sweat_smile:

As a workaround, in the terminal, run that same export command:

$ export PATH=~/.npm-global/bin:$PATH
$ expo --version

Just bear in mind that if you open a new terminal window you will need to do it again (unless it picks it up from .profile as it should.)

Understandably! I went ahead and followed the above instructions. Here’s the output from the terminal. Interestingly, expo --version is finally showing the correct version. I’m going to try to use expo start in the project directory.

1 Like

Amazing it worked!!! Thank you wodin, you’re awesome!!

1 Like