Lessons I learned from Issues with Installing React Native (expo) in Windows Powershell
Instead of doing the normal way of installing everything and learning while testing it out, I decided that it was good to just start with learning how React Native works.
I started googling and watching YouTube tutorial videos on React Native, learning all different tips and tricks I can do with the language. The biggest mistake was that I never installed React Native on my computer to try all this stuff out as I was learning them.
Now it’s been a week and I’m a day away from the weekly meeting where we have to show what we learned and get ready to start coding the project. This is when I decided to begin installing React Native. This is when I ran into my first error, installing Expo.
Getting Started and Installation
I learned through all the tutorial videos that I watched that using Expo is the best way for beginners to learn and create using React Native. So I started with going to expo.io to follow its tutorial for installing it.
First step is unnecessary, so I jump to NodeJS which I already have installed, but I probability should update it. That’s easy, just follow the link to their website and download the latest version for windows, step 2 Done. Step 3, install expo using NPM, looks simple. Quickly google the command and done, NPM in the latest version. Runs the command:
npm install expo-cli --global
Got a bunch of lines showing up in windows powershell and now expo should be installed, Step 3 done.
The Errors and Fixes
Step 4: expo init ProjectName…Error. Windows powershell told me that the term ‘expo’ is not recognized as the name of a cmdlet. Now I’m dumbfounded, didn’t I just install expo on the previous command and why is it telling me it’s not installed?
I spend the next hours googling why is my expo not installed, looking for ways to fix it. After hundreds of tabs, I finally found a code that allowed me to create a new project.
npx expo init ProjectName
This worked as I was able to create an react native project, and I can finally get to start working in the project.
However this really annoyed me, why do I have to use a workaround instead of using expo normally? This will be tiring and tedious if I have to do this every single time, and I probability will run into errors way down in the future. So I decided to spent more of my time fixing the root of the issue, rather than going down deeper in this rabbit hole.
After more hours of searching for a fix, I learned that I can fix it using yarn.
yarn global add expo-cli
So I quickly tried that, and it worked! Windows Powershell finally allowed me to create a project using expo without putting npx in front of it. Thus I decide to call it a day and code tomorrow, as this really tired me out and it’s about 2am in the middle of the night.
Now comes the day where the team was suppose to talk about what we did over the past week and I have nothing…an empty project with no code whatsoever. My team laughed at me for a bit but they forgave me in the end, told me next time I should listen to them and do the installation first. Always do the baby steps instead of being too ambitious and dreaming way too big.
I learned this lesson the hard way, and thanks to my teammates that they are so forgiving. The project is coming along and now I have some features that I can show my team in the next meeting. If anything that I learned through this, is that I have to start trying things out first, instead of just researching on what I can do. Due to using different operating systems, errors can pop up very easily during installations, so always make sure the installation is out of the way.
Note: It turns out the error I had was basically windows powershell not setting up the path to the Expo commands, Expo was installed there the whole time. Also if I just used windows cmd instead, I wouldn’t have ran into this error.
Another issue about windows powershell might be that you haven’t change it’s execution policy, which can be done by running powershell in admin mode and type:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned