问题
I installed the expo cli with
npm i -g exp
then I run
exp
and I get
-bash: exp: command not found
I'm guessing I didn't add exp to path. So how do I do this properly? Nothing I've tried so far works.
回答1:
This suggested 3 steps solution worked for me:
First check if
~/.npm-global/binis in your path:echo $PATH. If it isn’t there, you will need to add it to the path.Open up
~/.bash_profilethen add the following line to the bottom:export PATH=$PATH:~/.npm-global/binFinally, back in the shell, type:
source ~/.bash_profile
Hopefully that will have fixed your problem.
回答2:
I also had a hard time getting expo command to work on Mac. Here are the steps I took to get it working.
npm root -g shows the directory the global modules are installed in:
/usr/local/Cellar/node/11.7.0/lib/node_modules
That directory might be different for you. After confirming expo is in there, edit ~/.bash_profile and add the line:
export PATH=$PATH:/usr/local/Cellar/node/11.7.0/bin
Save & exit, then run source ~/.bash_profile
Now the expo command should function as intended.
回答3:
1. Find the path where expo is globally installed by npm:
npm bin -g
2. Add path from Step 1 to paths file:
sudo vi etc/paths
3. Restart the Terminal
回答4:
exp was replaced with expo
To install Expo CLI, just run npm install -g expo-cli (or yarn global add expo-cli, whichever you prefer).
回答5:
You should try npx expo init Your-App to test.
It worked for me.
回答6:
Following on this issue, I found I had multiple global folders so I started using a .npm-global folder as shown here: https://docs.npmjs.com/getting-started/fixing-npm-permissions
And now it's all clean and in control.
回答7:
I have found the solution. Here is the solution for react-native cli. Replace react-native with expo (exp).
回答8:
I had a similar issue.
-bash: expo: command not found
It turns out the command to install expo
npm install -g expo-cli was referencing an older version of node on my machine; when checked using npm root -g.
So I had to uninstall nvm/node, deleted any remnant folders & files of .nvm and shortcuts for nvm in /usr/local. Then reinstalled node and ran npm install -g expo-cli again.
That fixed my issue.
回答9:
sudo npm install --unsafe-perm -g expo-cli
来源:https://stackoverflow.com/questions/51775496/exp-command-not-found-how-do-i-add-expo-cli-to-path