installing npm package crashes react native application - reactjs

I've set up a React Native application that works fine with an emulator till I try to install the moment library to work with dates. This library won't even finish to install and then commands are not recognized anymore.
At the begining, everything runs correctly :
Then, installing the moment library :
Since the installation runs for ages, I did a Ctrl+C on it. Then the Metro and Android command won't be recognized :
However, these commands are still in the package.json :
From that point, the app is completely messed up. I have to erase everything and start all over again.
So? is it that npm packages cannot be used like in a regular React app? I don't understand what is going on here.
Thank you for your help.

Related

Fresh ReactJS project stuck at starting the development server

I am running a fresh react project with no single line of code written by me.
All I did was:
npx create-react-app my-app
npm install
npm start
The browser window opens and within my console window I see "Starting the development server". It is stuck there, have been keeping it up for over an hour with no progress.
I looked at different SO threads as well as many suggestions on other platforms. From limiting the RAM available to using another port, closing all browser windows, rebooting my machine - nothing helped.
Do you have any suggestions for troubleshooting?
Running on macOS 13.1 on M1 Pro.
It was the directory I started the project in. Using spaces and several special characters seems to break react as well es next.js which I tried next.

I cannot run this react app for some reason and I don't know what to do

I have been having difficulty running a react app on my terminal. It was all working fine yesterday until now. I've restarted my computer 3 times, installed yarn, made sure I cd'd into my project folder.
Every time I do yarn start I get several error codes.
I have created file directories, installed webpack, created a react app (npx create-react-app project-name) and every time I run it nothing happens. Which is weird because yesterday everything was fine.
Here are some screen shots. What do I do? I can't think of anything else. I've updated npm, I have the latest version of yarn.

React Electron App built with asar on gitlab runner creates JavaScript errors

i will just start my question a little bit structured:
background information
I am developing a React App with Electron on my Mac.
The customer uses this app on Windows 7 and 10.
The app is packaged with asar on a gitlab runner within a docker
the dockerfile for the runner is from electronuserland/builder:base
What works?
If I start the App locally I run the npm build script and start electron -> The app works fine!
If I package the App locally (on my Mac) for Windows and copy the .exe to my VM: -> The app works fine!
What does not work?
If my pipeline get triggered by my commit the gitlab runner starts to run the buildscript and the package script (The same ones I run locally for packaging and running my app) The build is "successfully" completed and the artifacts are stored on gitlab.
Then I download the .exe from the gitlab artifacts on my Windows VM and install the software. This absolutely works fine. The app can start up and some functions are pretty good working.
But there is a problem with a package (or maybe some more, i do not know yet) It is the react-bootstrap-daterangepicker. It gives me an JS error with $this.$picker.daterangepicker is not a function
I googled a lot and found existing problems with the package, but I do not understand why it is working when i package the app locally and not with the runner.
I removed my node-modules completey on my local machine and reinstalled them, and it is still working fine.
Do you have any idea?
Where could be a difference between my local environment and the runner environment that can cause this kind of problem?
I am pretty stuck in this problem, and you would be my hero if you can help me to fix this!
Have a nice day!
electron-builder recommends using electronuserland/builder:wine to build Windows targets. I'm not sure if this would fix the problem, but could you try using this image instead?
electronuserland/builder:wine — Wine, NodeJS 10 and required system dependencies. Based on builder:10. Use this image if you need to build Windows targets.
For more information: https://www.electron.build/multi-platform-build#provided-docker-images

React Native Expo Timout Error

I'm currently trying to learn react native. I created a project using create-react-native-app. After the project is created, I started npm start on the folder which shows the QR code. I've installed the expo app on my android phone and scanned the code but I'm getting a Uncaught Error: Timed out, no manifest in cache on my expo app and there is no stack trace given.
I've made it work a while ago but somehow its currently not working.
Im using windows 10.
npm 5.6
yarn 1.5.1
What I've done to fix it using Ubuntu was (I created my app using create-react-native-app):
open terminal
execute ifconfig
find network interface (wlp4s0, in my case)
execute export REACT_NATIVE_PACKAGER_HOSTNAME="IP_FOUND_BEFORE"
yarn start
SUCCESS! Finished building JavaScript bundle in 10069ms
Expo only supports the most recent 6 versions, this is because we have to have all the native code for each version on the client and that gets big fast 🙃💣. As of writing this v26 is almost out, that version of the expo client will not support v19 projects. Please make sure that your app is up-to-date by going to the app.json (or exp.json depending on how old your project is 😅) and checking the version number.
Outside of that, I would also recommend you start your project by calling exp start in the root folder of your project 💙
The problem that causes this is having multiple network connections. In my case, I have a virtual network connection which is used by the packager instead of the wifi connection. So basically what's happening is that my phone and my computer uses different connections. I've found a solution here: https://github.com/react-community/create-react-native-app/issues/598

can not install app on react native

I am trying to install an app with react native cli but get the
ERROR: JAVA_HOME is not set and no 'java' command could be found in
your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation. Could not install the app on the
device, read the error above for details. Make sure you have an
Android emulator running or a device connected and have set up your
Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
error...
And frankly this is sooo ofrustrating... Never had an issue with ionic or cordova nor android studio but infortunally, I need some native functions for my app...
Here is a background, at first the app was installing, I even was able to run hot reload on it then out of nowhere, without any change on the computer, I get this message whenever I try :react-native run-android".... I followed exactly what's on facebook github page but got this error... So i tried running a simple app on android studio and it worked...
Can someone have solution and also why this is happening out of nowhere?
Oh, I forgot right before I got this error, for some reason, I had to reinstall npm because nodeJs was not recognizing the npm command anymore
Ps : I even uninstall then reinstall android studio, uninstalled react-native-cli and reinstalling it, uninstalled react-native-create-project, reinstalled npm.
Check like this maybe this is the issue I guess:
1.Open the App that u have created using create-react-native-app or react-native init appName in android studio
It will be something like: appName>android>local properties(SDK location)
2.If u use windows pc/laptop then go to my computer right click for properties>advanced system settings click on that and find the environmental variables
and check if they are matching
Well, I got tired of it since none of the solutions on the web worked, I just wiped out my computer, reinstalled windows, got rid of all the non needed programs, reinstalled android SDK, java, react and... Still got this error... So I set JAVA_HOME (thanks youtube) and now it is working.

Resources