Read-only file system error when try to install pod on macbook m1 - reactjs

I'm trying to install react-native app on ios emulator but i have an error say it have no podlock, so i find solution here No `Podfile' found in the project directory
but i ran into a problem when i try to pod install in ios folder, it show like this
Please help, i'm totally new to mac, i never using mac before, thank a lots

There are some Libraries that break with pods with arm-64 MacBook pro's. I have faced the same issues while setting up with React-Native. You can duplicate your terminal and enable the open with the Rosseta option. This option will run the pods using the Rosetta emulation. There are still many libraries that break on the new MacBook Pro.
You can follow this link for adding a duplicate terminal that uses Rosetta: Adding Rosseta Terminal

I solved, it turns out this folder is read-only, don't know why but it was a document folder, I move the project to the top level of the document, like document/project, and it works, but place project in document/a/b/c/project it not work, so weird, still looking for an answer.

I fixed it by running pod install with the parameter --project-direcotry=~/<path-to-my-project> like this:
pod install --project-directory=~/<path-to-my-project>
Also, if you need to run npx install-expo-modules, could be achive by it:
npx install-expo-modules ~/<path-to-my-project>
Apparently, the simple fact to set relative path solved it ;)

Related

Work on ReactJS that was developed on Linux/Mac on Windows

I have experience developing ReactJS apps on Windows (with VSCode and Git/Sourcetree), but I have never used Linux/Mac.
Now I'm going to work (temporarily) with a team who are working on a huge/mature ReactJS project. The problem is they're all on Linux and Mac (they use Git too).
I am hoping to be able to just use my Sourcetree and VSCode and everything on Windows, but I imagine at least the scripts in their package.json won't easily run on my Windows machine?
If anyone has faced a similar situation I would really appreciate some advice so I could prepare.
To work on a project developed on Linux, and make Linux commands from the package.json scripts run on Visual Studio Code on Windows:
Install Git for Windows
Set VSCode to use Bash
Run this command to make npm scripts run in Bash:
npm config set script-shell
"C:\Users\hardi.sempuno\AppData\Local\Programs\Git\bin\bash.exe"
(To undo this: npm config delete script-shell)

React server on browser is not auto-refreshing

I was following this react course from YouTube.
I installed the create-react-app successfully and also ran the localhost server successfully on my browser afternpm start.
But the problem is that whenever I make a change in the component and save, I have to keep refreshing the browser by myself (browser is not refreshing automatically on save). But the browser of the teacher in that video refreshes automatically.
Please help me. Am I doing something wrong? or what should I do?
I think the best option is to use: npx create-react-app your-app-name when creating your apps so you can always have the most updated version. As per the docs: https://reactjs.org/docs/create-a-new-react-app.html
The best option would be to create your project in a C-drive ( any directory/folder in C drive), where your node packages were installed during the first setup of the node. I had a similar issue when my project was in D-Drive's Directory but switching to C Drive's Directory "C:\Users\USERNAME\Documents\ReactProjects\frontend\src" fixed my issue.
There might be different reasons why this is happening. Try one of the following solutions:
1 --> Increase the maximum number of allowed watchers in your linux environment. This is a known issue when running webpack inside of a VM like WSL2, as it happens when you execute npm start. To do so, issue the following commands in your terminal:
sudo nano /proc/sys/fs/inotify/max_user_watches
Replace the number you see with 1048576 and save the file. Then type exit and relaunch the terminal. Try npm start inside of your project folder again.
2 --> If the above didn't work, try setting the CHOKIDAR_USEPOLLING=true environment variable in your linux environment, which will reflect on your react development environment. Normally you would put this in a .env file inside of your project folder, but adding the variable to your .bashrc file will make it work with any React project you are working on. If you are only experimenting with React for now, I would recommend this solution. This change is unfortunately necessary when working inside of a virtual machine like WSL. Add the line export CHOKIDAR_USEPOLLING=true at the end of your .bashrc file. To edit your .bashrc file:
sudo nano ~/.bashrc
Then save the file and exit/relaunch your terminal. Try npm start inside of your project folder again. Hopefully this should fix it.

Hot reload stopped working after adjusting environment for work requirements

I started a new developer role a few days ago and made some environmental changes to adapt for work. Since then, my hot reload/fast refresh has just stopped working entirely. Changes don't show up even if I refresh the page manually. Only shows changes when I stop the dev server and restart it with 'npm run dev'. The triangle indicator at the bottom right should be active, showing active reload of the window (this no longer shows up consistently either, and if it does the page gets reloaded, but alas the proposed changes aren't visible)
Context:
It has this effect on all NextJS and react applications of mine. Even running a basic project template off the NextJS examples page shows no hot reload working.
I researched this issue and it seems wrong imports (e.g. importing components using lowercase or files in the pages directory being capitalized) can cause this, but I combed through the code and can't spot any issues (of course, I could be missing it but my codebase is over 300 files).
Service workers in the background can cause issues, but I cleared my browser of all of them to be sure and it still doesn't fix it.
I installed ngrok for tunneling for work purposes and docker-compose to handle the work dev. environment.
Made sure I'm using the latest Next version. Even deleted node_modules and ran npm install. Deleted .next and the out folder and still no luck.
Anybody have any ideas or clues to what I should try next? Is it related to the stuff I installed for work? Something related to VS code or WSL2? Seems so puzzling it kind of just happened overnight. Thanks for any insight or advice!
System information
OS: Windows (WSL2 virtualization for VS code)
Browser: Chrome
Version of Next.js: 10.0.3
Version of Node.js: 14.8.0
Deployment: npm run dev for development work; amplify publish for AWS hosting
The problem is with WSL2. I use WSL2 inside VS Code; which is a big performance upgrade in the Linux environment. The problem is WSL2 is actually in a 'virtualization' and thus cannot send information from VS Code AND the browser (localhost:3000) at the same time.
It's a big issue they are working on and there is no fix yet for it. That's why fast refresh doesn't work because localhost is not receiving the changes being made. Either proxy through or revert back to WSL1 https://github.com/microsoft/WSL/issues/4769
Solution provide by OP on question section
Add a .env file or a .env.local file to your root and put this line on it:
WATCHPACK_POLLING=true
Now, restart your server.
Thanks I encounter the same issue with WSL2. I just switch to windows terminal and it works.
If you run Poweshell as administrator and run
wsl.exe -l -v
This will give you th eversion of wsl your distros run on.
I am personally using Ubuntu, and this is the output
Ubuntu Running 2
docker-desktop Stopped 2
docker-desktop-data Stopped 2
To switch to wsl 1,
Run
wsl.exe --set-version Ubuntu 1
and if you wanna switch back,
run,
wsl.exe --set-version Ubuntu 2.
This worked for me.
In my react projects, I just add in my .env file at the root project folder the values
FAST_REFRESH=false
CHOKIDAR_USEPOLLING=true
and it works! enjoy!
The problem is with WSL2. I use WSL2 inside VS Code. But React JS and Next JS projects don't auto-reload. So, add a .env or .env.local (recommended) file to your root and put these lines on it:
WATCHPACK_POLLING=true
CHOKIDAR_USEPOLLING=true
Now, restart your server.

How to best transfer a React project from Windows to Linux

I have several simple React projects that I have built using create-react-app on Windows 10 and wish to transfer them to my Linux development system. I don't think it's as simple as zip and unzip. Can someone suggest the appropriate way to do this? Or should the above mentioned zip/unzip work? Thanks in advance.
As long as you get the source code over, anything is fine really. A recommended way of doing that is transferring everything except for the node_modules folder, as running npm install can install OS-specific dependencies as well.

Create React Native App run on device

Okay So I'm extremely confused on how this all works...
I want to run my app on my device and not through Expo.
So I'm reading the Facebook documentation and told me to open up my ios directory and open up the xcode file. While I proceeded to look inside my directory of course I don't find my ios folder...lol (Don't understand why they don't tell us the step to actual create the folder..)
So I'm google and googling and find that I needed to eject. But in that documentation it told me it was permanent... Doesn't sound safe at all.... So I did it anyway and it created my ios folder.
I opened it up on xCode and deploy it to my phone.. Why is that the app looks completely different from the one it ran on expo locally...
If you look at the picture below, they're two different app..lol. Like come on what sort of trickery do I need to go through just to have my app run on my device without going through expo.
Why is it showing 2 different apps?
Future wise, Should I only eject when the app is completely done? Since I can't run it on expo anymore.. hence the permanent changes.. How would I test native device features? This honestly makes no sense.
How to start working on react-native ios without expo.
brew install node
npm install -g react-native-cli
react-native init AwesomeProject
open ios/AwsomeProject.xcodeproj in xcode
You can also install cocoa pod and use AwsomeProject.xcworkspace.
In account add ur ID Apple Id and download certificate manually
In general menu add your apple id and press run
For next time open terminal
cd project
react-native run-ios --device "iPhone"
Note: Write your device instead of iPhone. Hope I made things clear for beginners please feel free to correct me if i am wrong.

Resources