Why expo-cli must be installed globally?
Asked Answered
U

1

8

The official way of working with expo-cli is to install it globally, see https://docs.expo.io/get-started/installation/#installing-expo-cli:

Installing Expo CLI

# Install command line tools
npm install --global expo-cli

However, I never found any explanation about why it is supposed to be global (other than that this simplifies the initial expo init command). To my thinking, having a global package undermines the whole idea behind npm and local node_modules. Essentially, expo-cli is a direct dependency of the project. It's used for running the dev version with expo start and also for creating production builds.

Different versions of expo-cli will work differently, they may even expect different values in app.config.ts. That means it's not safe to upgrade expo-cli globally for one project and then return working with an older project which has been created and maintained with an older version of (global) expo-cli.

None of this would have happened if expo-cli were a normal local project dependency like expo (the SDK package).

So, my question is: is there a real reason for keeping expo-cli global? What do I lose if I move it to local project dependencies? How come Expo documentation never even mentions such option?

Unpaged answered 9/11, 2020 at 8:8 Comment(2)
I'm curious what the answer is on this if you find it. I can't get the latest version of expo-cli to work if installed locally to my package, it can only work globally. I was able to use it locally previously.Astigmia
I've simply installed it as a devDepedency and everything works fine so far.Volley
M
0

In Expo SDK 46 they introduced a new “Local Expo CLI”.

However, this was possibly because of the fact that if you don't have or delete the "node_modules" directory, you can't reinstall with "expo install".

Mcdavid answered 20/5, 2024 at 3:8 Comment(1)
Although this doesn't really fully answer the original question, I'm marking this accepted as it explains straight to the point why the original question is now outdated and irrelevant.Unpaged

© 2022 - 2025 — McMap. All rights reserved.