npm server fails to start on brand new react native project - react-native

I just started on a fresh dev environment with Xcode 7.2.1, and installed react-native (0.20.0). I initialized a test project to see if it would run, and I got the following error:
~/dev/TestProj/node_modules/react-native/packager ~
packager.sh: line 11: node: command not found
The iOS Simulator screen says:
Could not connect to development server.
Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate
URL: http://localhost:8081/index.ios.bundle?platform=ios&dev=true
Sure enough, if I go into the project folder in a terminal window and run 'npm start' from there, the packager starts and everything works. In my experience the packager should run by itself though when you run a project with React Native. Am I doing something wrong here or is there an issue? Never had this happen with previous versions of RN.

I moved on to trying to get my old project working, and while trying to use npm to add new packages, I added the following to my ~/.profile. I'm guessing this fixed it:
export NPM_DIR="$HOME/.npm" [ -s "$NPM_DIR/npm.sh" ] && . "$NPM_DIR/npm.sh"

Related

Unable to build app for production using Vue-tour library

We are not able to build the app into production. While we run npm run build we get an error, "expected and declaration or statement expected in a jsx file".
Steps to Reproduce:
Install v-tour and setup all tours for testing in local.
run npm run build
check the console for error
Expected behavior:
The app has to properly be built for production without any errors
Desktop (please complete the following information):
OS: Windows 11
Browser : Chrome
Version : 105.0.5195.127
Vue : #vue/cli 4.4.6
Node : 14.19.0
ScreenShots:
I've added an issue in v-tour's github repo

Getting Building iOS bundle error when trying to build an android app - expo -react-native

I was able to build app using expo build:android previously. However, after upgrading to latest expo version I get following error:
connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.
I also see the following lines in the log:
Publishing to channel 'default'...
Building iOS bundle
I don't added ios to my app.json, I only need to build an android apk. To do that I use expo build:android -t app-bundle
I also removed package-lock.json and node_modules and run npm install, but I get the same error.
I run expo start on another cmd and then run expo build:android -t app-bundle still get same error
Also when I clear expo cache, see the following log:
Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'
I had faced same issue myself and found the solution. Expo is looking for localhost:19001 which is not running. Just follow following steps and it should work as expected:
Run expo start no terminal and once it opens up the
browser where you will find this line written Starting Metro
Bundler on port 19001.
Now open another terminal instance and run expo build:android.

Failed to load bundle - Could not connect to development server

I've been looking for a solution to this issue for a day now but couldn't fix it.
I have not used react native for a month when everything was working fine.
Now, if I try to run an existing project that used to work (react native 0.59.5) or a brand new project (react native 0.59.9) with the iOS simulator on my mac, I get the error:
Failed to load bundle - Could not connect to development server
Any idea how I can fix this?
Ok found the issue. Was thinking it might be watchman related issue and wanted to use the command brew reinstall watchmanto reinstall it. By running this command, I found an error
Error: Xcode alone is not sufficient on Mojave. Install the Command Line Tools: xcode-select --install
Looks like the command line tools for xCode was not available anymore.
I launched the command xcode-select --install and then reinstalled watchman just in case. It is now working!
Couldn't connect to development server error
This error is received when the metro bundler isn't running in port 8081. To start the bundler, from project folder run:
npm start
Now, try reloading your app (ctrl + R for iOS / r+r for Android).
Also, check your terminal in case the project failed initial build due to some error.

Expo XDE is stuck when opening one of my projects

This has happened to me twice now when working on this project. I open the project using expo XDE and it just hangs there loading and never actually opening my project. The first time it happened I just created a new project and copied my code over. I don't want to keep doing that. I've seen posts where people talk about the wifi connection and mine is working just fine.
https://imgur.com/a/0CWDDOC
This second time around I tried running 'exp start' from the CLI when inside my project directory and I get this error
https://imgur.com/kxxIELK
I am able to open my other projects via the command line and with the expo XDE app.
Let me know if there is any other information I can provide!
Versions:
expo XDE: 2.24.4
npm ls react-native : react-native#0.55.4
npm ls expo : expo#28.0.0
npm -v : 6.1.0
node -v : v8.11.1
exp -V : 55.0.4
watchman version : 4.9.0

Getting error while creating a new Project

I'm new to reactnative. I have followed steps to install reactnative properly but, while creating a new project, I'm getting an error. I'm using Windows 7 64 bit with i3 processor.
c:\ReactNativeProjects>react-native init AwesomeProject
Command npm install --save --save-exact react-native failed.
My Folder contains only one file
Since you are starting to use React Native, consider using Expo, I've used it and it makes developing, debugging, testing and deploying to the apple store and google play easier.
According to the official docs:
Expo is the easiest way to start building a new React Native
application. It allows you to start a project without installing or
configuring any tools to build native code - no Xcode or Android
Studio installation required (see Caveats).
Assuming that you have Node installed, you can use npm to install the
Expo CLI command line utility:
npm install -g expo-cli
Then run the following commands to create a
new React Native project called "AwesomeProject":
expo init AwesomeProject
cd AwesomeProject
npm start
This will start a development server for
you.
I've answered a question in SO for the steps and what happens when you build your .apk and .ipa files using Expo, have a look at that as well.
These are my steps to get rid of this error:
Please upgrade your npm
npm install -g npm#latest
Run npm cache clean command in Command prompt ( With some element of doubt for cache presence)
3.Ran react-native init in command prompt as Administrator (on Windows OS), hoping works well with sudo react-native init on Mac OS
If still problem persist make sure that you have followed each and every step mentioned in Documentation i.e. installed JDK, PYTHON, NODE.
Refer to this link For windows