3

I'm a bit confused about the relationship between using the local cli and using the global one. Two kinds of confusion actually:

  1. When there's a command that both support like install what's the difference between running the local (with yarn expo install) and the global (with expo or expo-cli)?

  2. When the only way to run a command is to run global, what's going on? E.g., does expo doctor still work as it always did?

All in all I'm not at all clear why there are now sometimes two ways of doing what looks like the same thing, and sometimes no way (without going global), or why it's so easy to accidentally go global when that's not what's intended (e.g. forgetting to prepend yarn to expo) — and whether that matters at all (which I guess makes a third kind of confusion, actually).

What am I missing?

orome
  • 45,163
  • 57
  • 202
  • 418
  • I [gather it's something like this](https://discord.com/channels/695411232856997968/695411232856997971/1019310317219631195), but I'm not sure: (1) there's no difference except that local runs faster (they will both do exactly the same thing if they both support a command) and so (2) stuff that's just in global just hasn't (yet) been migrated (or won't be)? – orome Sep 13 '22 at 18:20

1 Answers1

3

Taken from this blog post:

Unlike the global CLI, the local CLI is installed in every project and stays versioned with the runtime code — meaning projects are easier to set up, stay working longer, and the tooling updates less often.

The Expo CLI is now bundled with the Expo SDK – therefore it only needs to support the SDK Version it's bundled with, making it a lot faster. Revisiting an old project might be more stable in the future, because the local CLI beeing always compatible with that old Expo SDK it was once bundled with. They have committed to move all commands to the local CLI (e.g. doctor currently still needs the global CLI). Therefore the local CLI should always be your default, use global CLI only if prompted to. Example:

$ npx expo doctor

  $ expo doctor is not supported in the local CLI, please use expo-cli doctor instead

TL;DR: If a command works locally, prefer using it over the global option by using:

npx expo [command]

The local CLI will tell you when and how to use the global CLI if necessary.

KiwiKilian
  • 981
  • 1
  • 7
  • 10