React Native hangs forever - javascript

I have an issue trying installing a new project for React-Native. It hangs with this:
react-native#0.33.0` requires a peer of react#~15.3.1 but none was installed.
npm verb exit [ 0, true ]
npm info ok
And It stay like that forever.
npm 3.10.7
node 6.2.1

I also ran into this issue and can confirm that the problem is watchman. I had used homebrew to uninstall/reinstall and was still running into the same issues. My steps to solve were the following:
Uninstall watchman with homebrew
Delete the contents of the /usr/local/var/run/watchman/ folder
Re-install watchman with homebrew
I was able to figure out the extra step of deleting the contents of the watchman folder from these two github issues:
- https://github.com/facebook/watchman/issues/361
- https://github.com/facebook/watchman/issues/358#issuecomment-246672605

After few days going around, the problem was Watchman, Uninstalled and re-installed again did the work.

Try the following steps:
Remove the current watcher: watchman watch-del-all
Delete your node_modules folder
Run npm cache clean -f
Run npm install
Check if your react native project can run with your simulator now:
react-native run-ios

Related

MAC M1 Something went wrong installing the "sharp" module

Running npm run dev (gatsby develop) on MacBook Pro M1 chip exit with Error: Something went wrong installing the "sharp" module
Running npm run dev MacBook Pro intel chip works fine.
I've seen similar post which did not solved my problem :
When i run "gatsby develop " Something went wrong installing the "sharp" module error is showing
Error Installing Gatsby Starter 'Something went wrong installing the "sharp" module'
Gatsby Develop : Something went wrong installing the "sharp" module
I've update my node version in case any fixes had been made but I still got the error on node v16.0.0
On this github issue they recommend to follow theses steps which did not work.
rm -r node_modules/sharp
yarn install --check-files
On this github issue they recommend to install NVM and downgrade node version. NVM has some difficulties to install on my M1 chip so it is not a good option for me.
I have also tried to do the following steps which did not work as well
rm -rf node_module
rm package-lock.json
npm i
Any idea what can I do to fix gatsby develop on M1 chip ?
Following these steps from this discussion solved my problem.
xcode-select --install
brew install gcc
brew reinstall vips
brew info vips
npm i
Then you can run gatsby develop
I had to downgrade node from 17 (nvm is ideal here) - it worked on 14.
I tried this command, it will probably workout for you too.
all you need to do is to install sharp with unsafe perm which gonna fix the error
npm install sharp --unsafe-perm
keep in mind that this just fix it for the time being and i suggest you to update the xcode command line tools for the main fix
Use sharp 0.29.0 or more will fix this issue
Resolved by removing the current vips
brew remove vips
rm -rf node_modules
yarn install
https://github.com/lovell/sharp/issues/2588#issuecomment-783254806

How to install react app without an error

Hello guys i am trying to install react into my system but from 2 days i am facing the error for several times now. At first, i have used these commands to install react app and it was working fine for me
1. npm install -g creat-react-app
2. create-react-app reactapp
but form 2 days i was facing error while choosing these options to install, therefore I visited https://create-react-app.dev/docs/getting-started/ where it was clearly stated- If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version. Then i used the command npx create-react-app reactapp but i am facing this error. I have multiple time uninstalled nodejs and installed, also have used the command npm cache clean --forcetoo. But not working!!!!
e:\react-learn>npm uninstall -g create-react-app
removed 98 packages in 5.031s
e:\react-learn>npx create-react-app reactapp
npx: installed 98 in 39.888s
Creating a new React app in e:\react-learn\reactapp.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! Unexpected end of JSON input while parsing near '...wRDiDz3X/FqXhQ==","
sh'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dell\AppData\Roaming\npm-cache\_logs\2020-05-23T12_48_46_9
79Z-debug.log
How to resolve this error???And one interesting thing you know when i copied my previous project and run npm start it is working fine. What is the issue reactapp is justing eating my nerves...
Try clearing your cache and try again.
You can run
npm cache clean --force
or
npm cache clear --force
Try using npx create-react-app client --use-npm. Sometimes some issues arise due to package managers .

npm start is not working in cmd and it is showing error as shown in image?

This image contains details about the error when I am typing npm-start
I have created a react-app using create-react-app. I have created another app using the same but when I type npm-start, it displays an error and localhost:3000 stops working.
Missing npm package
Use the cmd to install npm package npm install
Check the docs here
To solve this problem you can follow these steps.
First, reinstall node_modules:
rm -rf node_modules/ && npm i //(rm -rf will only work if you have macOS for windows you need to delete node_modules manually)//
Then, start the project:
npm start
or
yarn start
This error solved by few easier simple steps. That steps are
Go to your setting
Open your environment variable screen
Delete ComSpec variable completely and click ok
Uninstall your NodeJS
Reinstall your nodejs setup,
Finally it will be work

'expo' is not recognized as an internal or external command

After running npm install -g expo-cli and successfully installing the packages globally, expo is still not recognized as an internal or external command. Does anyone know how I might get around this issue using windows 10, or what to do in terms of something like a path variable.
Probably the only thing missing is to add the expo executable to your path.
For Windows 10, you can simply add the npm folder to your path environment variable.
Hit Windows key and search for Environment variables.
Inside the Path variable under System variables, add a new
entry (entries are separated by semicolons) with this content (without /node_modules ):
%USERPROFILE%\AppData\Roaming\npm
OR if you are using yarn C:\Users\{USER}\AppData\Local\Yarn\bin (as #Qwerty mentioned above)
Open a new command prompt and enter
> expo
You will see something like this:
I may be too late to answer this, but for people looking for the same error this is what worked for me.
Install yarn if you don't have it. I used the command choco install yarn (you'll have to install Chocolatey). If you have scoop installed, scoop install yarn also works.
Use yarn to install expo with yarn global add expo-cli.
expo start should work now. yarn start and npm start should also work.
Hope that helps!
I wondered it was working last night when I first installed and run the "react-native" project but the very next day it showed me the same error as yours.
Here is what I did in windows 10 Operating System:
Add the following path :
environment variable > System Variables > PATH > C:\Users\YOUR_USERNAME\AppData\Roaming\npm
Now I ran the following commands one by one in CMD:
i) npm -g uninstall expo-cli --save
ii) npm install -g expo-cli
Now start the Project and run npm start and now it works for me.
I didn't try this article one but it also shows the solution for the same problem,
see here
Added These path of npm like this i have the same issue i fix it by adding the path to environment system
C:\Users\abobakr\AppData\Roaming\npm
After that close CMD and open it again it should work believe me
go to the environment variable, then in the user variable section find Path and press the edit button, you will see a new window, press new and add the following
%USERPROFILE%\AppData\Roaming\npm
then press ok. Now,
expo --version
Here is the solution I came out with.
I ran npm list -g
then copy the directory on the first line and paste in your system enviroment variables under the variable name 'path'
close all the terminals and run expo or any other command.
This worked for me :
Download latest version of nodejs - https://nodejs.org/en/download/
After installing nodejs reboot your computer
install : npm install --global expo-cli
Generate a new project with - npx expo-cli init projectName
cd projectName
npm start
If it still doesnt work or you can't access npm. Try setting the path with the Windows PowerShell:
Open Windows Powershell as Administrator
Type: setx path "%path%;C:\Users\USERNAME\AppData\Roaming\npm"
It worked for me.
Re-install node.js and
then run npm install -g expo-cli in command prompt.
If you are using Windows 10 or 11, the solution to edit your Path variable works well.
Just make sure that you replace "YOUR_USERNAME" with your username on the computer:
This means that if my username is "Green", I will replace YOUR_USERNAME here:
C:\Users\YOUR_USERNAME\AppData\Roaming\npm
to
C:\Users\Green\AppData\Roaming\npm.
This article is very detailed in solving the problem in case if the above does not work for you.
I had the same problem last night, and I've recently started my journey in ReactNative. So, there might be better answers out there.
If you're following the ReactNative Official documentation, the first time npm start works fine, the subsequent ones throws an error saying expo is not recognized. I got around that by running expo start and not npm start ( which basically is the same thing but doesn't work for some reason ).
So, mine looks like a work around rather than an explanation as to why this happens or how to permanently fix it.
For me,
i uninstalled node.js,
i re-installed node.js,
i ran npm install -g expo-cli,
then ran expo --version (the expo command began to work).
Hope this helps.
This worked for me:
You must uninstall node js then install it again.
You must run npm install expo-cli.
It will solve your problem
This is a more general problem where your global node modules are not in your system path. This question is what you are looking for: Nodejs cannot find installed module on Windows?
I have fixed this in Windows 10 by setting Path C:\Users\[USERNAME] this line save my hrs
uninstall expo using this command
npm -g uninstall expo-cli --save
and reinstall expo using this command
npm install -g expo-cli
then it will work properly
I faced same problem and it was not getting resolved by "npm install --global expo-cli".
Global CLI was having error as SS below -
npm list -g --depth 0
Followed below steps to get it resolved
npm uninstall --global expo-cli
Deleted global package causing error C:\Users<USERNAME>\AppData\Roaming\npm\node_modules\expo-cli
npm install --global expo-cli
And expo cli worked.
Happy coding!!!
If you need a solution to Run Expo command without Environment Variable update then on your terminal use below command for windows system:
R:\> C:\Users\{user}\AppData\Roaming\npm\expo.cmd init {projectname}
Where you directly point the expo.cmd file rather than specifying in the environment variable.
And update the expo to C:\Users{user}\AppData\Roaming\npm\expo.cmd in package.json to run the project.
// package.json
"scripts": {
"start": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start",
"android": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --android",
"ios": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd start --ios",
"web": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmdstart --web",
"eject": "C:\\Users\\{user}\\AppData\\Roaming\\npm\\expo.cmd eject"
},
If you are using yarn global add expo-cli, try npm install -g expo-cli.
I don't know why but when i go into C:\Users\%{user}%\AppData\Roaming\npm there isn't the expo package(and other packages that I thought I install globally by yarn) but there are other that I installed globally by npm.
If adding C:\Users\%{user}%\AppData\Roaming\npm to PATH variable doesn't work, give this a shot.
If you set the environment path as said in other replies and the command is still not recognized, try running whatever you're using to execute the command in administrator mode.
I'm using VS Code terminal and expo was not recognized until I ran it as administartor.

"Error watching file for changes: EMFILE" when init a react-native project

I want to init a react-native project, and steps:
First react-native init testproject
then react-native run-ios
Error watching file for changes: EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"Error watching file for changes:","filename":null}
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1008:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)
Operation System Edition: OS X 10.12
Reinstalling watchman fixed this error for me.
brew uninstall watchman
brew install watchman
One more thing that worked for my teammate and may work for you is deleting node_modules directory completely and running
npm install
Note that yarn install did not work in this case.

Categories

Resources