expo is not recognized as an internal or external command - react-native

I am having trouble getting expo start to work.
I completely uninstalled both expo and expo-cli with npm and yarn and then installed expo-cli globally with npm and I still get the same error. I think it has something to do with the most recent expo-cli update, because it was working perfectly fine. So how can I install an older version of expo-cli?
I also don't see any path in the environment variables? Could that have something to do it?

For some reason, the update messed with the path.
So I had to go to edit environment variables and add another line to the variable "Path" under the system variables.
Don't hit new. Click on "Path" under the system variables section and add a new line there. and use "%USERPROFILE%\AppData\Roaming\npm".
Then open a new command line and it should work.

Related

NVM breaks sporadically because of resetting PREFIX environment variable

The Problem
I am trying to run a react-native iOS application from the CLI. This has not been a problem in the past, but haven't developed in react-native for over 6 months. Last week in about 40% of the cases when a (zsh) terminal is opened nvm breaks because of the environment variables. This could happen whether I open the terminal myself, or when VSCode opens a new terminal for the metro bundler. Running from Xcode always works. Closing all zsh terminals and then opening a new one seems to resolve the issue. Additionally, it happens (more) often in the terminal that is opened by VSCode for the metro bundler than when I open the terminals myself. Lastly, the issue seems to 'stick' once it starts occurring I need to close all terminals for the error to be resolved.
Error that is shown
nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
What I have tried
Changing environment variables
1.1 When the zsh terminal does NOT show the error:
I tried running npm config delete prefix, in hopes of changing the config so that the issue does not pop up anymore. I can't run this command when the error is shown, because I have no access to node or npm.
1.2 When the zsh terminal does show the error:
I can 'fix' the terminal by unsetting the PREFIX variable with unset PREFIX and then asking nvm to use a version of node. However this only fixes that particular instance of the terminals. The only sure fire way is to close all terminals.
unset PREFIX
nvm use v14.15.0
Updating react-native
Speaks for itself, a colleague mentioned that it might be caused by a bug in react-native. Did not resolve the issue unfortunately.
Conclusion
It seems as though something (re)triggers setting the PREFIX environment variable when I try to run the react-native iOS project. I am honestly completely lost as to what might be causing this and any help would be truly appreciated.
I had this issue too, as have others.
Are you using yarn or npm to run the React Native CLI? If so, and these were installed with Homebrew, these might be conflicting with your nvm installed node. Try removing these:
brew uninstall yarn
brew uninstall npm
This should leave behind the version of npm that was installed with nvm, check this by running:
which npm
This should return a path pointing to your local .nvm installation. If it shows /usr/local then it was not removed correctly, you might need to follow the npm removal instructions.
Once this is done, if you use yarn then install it with npm:
npm install -g yarn
Run the React Native CLI once again, it should now work.
More details on this resolution: https://github.com/nvm-sh/nvm/issues/1645#issuecomment-850376572

Why is preact not getting recognized in the terminal even after installing it?

I have installed Preact but it’s not getting recognized in the terminal. First, I went to the official website of PreactJS. The doc says that I have to run npm install -g preact-cli. As I am using Yarn, I ran yarn global add preact-cli. It was installed successfully but with a lot of warnings. Then I ran preact create default first-preact-app. But it's showing an error that "The term 'Preact' is not recognized as a name of a cmdlet, function, script file or executable program."
I have tried force cleaning the cache and reinstalling preact-cli. But it doesn't work. Two of the warnings are that preact and preact-render-to-string have unmet peer dependency. So, I have installed them also. But it still doesn't work.
I have tried running npm and experimented with the commands also. But it didn't work. So, how can I fix the problem?
I have run these commands using Powershell and Git bash on Windows 10. I am trying to install Preact 10.5.12 using Yarn 1.22.5. And a point to be noted, I tried running yarn dlx but it returns an error that "command not found". And when the installation of preact and preact-render-to-string gets finished, yarn gives and warning that they have no binaries.
EDIT: Perhaps, it was a problem with Windows. The problem has gone after reinstalling it.
Your problem almost certainly is that preact-cli was not on your PATH - a list of programs that are globally accessible.
For what it's worth, we don't recommend installing globally. The site may still say that but the repository correctly recommends using npx instead.

Error: option 'name' clashes with existing property 'name' on Command

Some context: I've recently been trying to update a react native project that uses expo, since I have not worked on the project for about four months. I believe I finally was able to successfully upgrade the project as expo is starting. The issue is that I am now having some trouble with some of the newer modules I just installed with npm. This error seems to be coming from me not knowing how to use the commander module. Additionally, I do not believe that I have a thorough understanding of modulues in react native/expo. I am using ubuntu 20.04 via windows terminal.
Error:
I did go to the website mentioned in the error. I believe that this link - https://github.com/tj/commander.js#avoiding-option-name-clashes - is what will solve my problem. However, I am confused as to where I should put the example file and how to use it.
I am not very well versed in modules for react native/expo and it is quite possible that I do not need to use this module (I thought that installing it would make my react native program run, but that does not seem to be the case).
Thus, I am looking for advice on either how to use this module, or on whether or not I should be using these modules (after updating node and then expo, the following modules could not be found every time I ran npm start, so I decided to install them using sudo npm install module_name -g since some other stackoverflow/github pages recommended that):
fs-extra
terminal-link
chalk
getenv
commander
#expo/xdl
Any help would be appreciated, and I would be happy to provide any more information that would be relevant.
I was not able to figure out a way to make the project work with the above modules. So, I followed the advice of a post I made on the expo forums (I posted similar context there and also the answer that I wrote below).
If you do not want to click the link, here are the steps below:
Basically, I uninstalled expo using the following command: npm -g uninstall expo-cli --save && yarn global remove expo-cli. Then I proceeded to remove the .expo folder from my home directory. More details on these two steps can be found here.
After that, I reinstalled expo using npm install --global expo-cli, from the expo documentation, in the install section.
Then I closed my terminal, reopened it, and ran expo whoami. The command returned recommending an update, so I followed the provided update command (which I believe was just npm install --global expo-cli again).
I closed the terminal, reopened it, and ran expo whoami again. This time I was just met with "you are not logged into expo" (or something along those lines). So, everything seemed up to date.
I then went to project and ran npm start and it worked fine.
Note: You may need to use sudo for any uninstall and install commands above (your terminal will likely tell you if you do).
Note Clearing cache for npm and yarn may take some time. Additionally, the first time you run npm start may also take some time. I'd say all in all this took about two to three hours, but my computer is also not the best.

'vue create xxx' - nothing happens

I have installed the latest Vue CLI, with npm install -g #vue/cli#next, having uninstalled the previous 'vue-cli'. Now when I try and create a Vue application with e.g. vue create vue3-todo, nothing happens. The command quickly executes without error (but without any prompts), and nothing is created - the directory remains empty.
Clearly something is not right with my Vue CLI installation. Any suggestions as to what the issue might be and how I can clean things up?
I would start with running this to uninstall:
npm uninstall -g vue-cli
Then check my node version. It's recommended to use node v10+ for the latest CLI.
I'd probably do a system restart just because and then reinstall:
npm install -g #vue/cli
I have got to the bottom of this. This is under Windows 10, and I noticed there was a an entry of 'C:\Program Files\nodejs' in the PATH environment variable (under 'System variables'). I looked in that directory, and sure enough, there were a bunch of 'vue*' files. I deleted these and now when I call 'vue' I get the current version as I should. Clearly these were taking precedence over the versions in my AppData/Roamin/npm directory.
I have no idea why these files were there in the first place. I am hoping that having deleted them I do not break anything.

Endless loop on installing Expo CLI

I try to execute command npm start on terminal on my Mac.
It prompts me to install Expo CLI , I say Y, wait until installation to finish, then I end up in an endless loop where it keeps prompting me to install Expo CLI again:
This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]?
Any ideas why I'm having this?
Turns out my profile file was messed up (I had previously installed Anaconda which seems to have changed .bash_profile entries)
I removed all those stuff and inserted the correct $PATH that bash should look into. That was it.
I have faced similar issue. I have a few solutions. Try if they work out for you.
In case you have added the path multiple times remove it.
Ensure that there are no blank spaces or blank lines after the Path.(This one worked for me)
Manually install expo-cli with npm install expo-cli before running npm start. This worked for me.