Create New React Native app - node.js

I am getting an error on creating my first react native app.
I am using following guide -
https://facebook.github.io/react-native/docs/getting-started.html
https://github.com/react-community/create-react-native-app
$ npm install -g create-react-native-app
--Worked fine
$ create-react-native-app my-first-native-app
--app created without errors
$ npm start
--gives error
Error: React native is not installed. Please run `npm install` in your project directory.
1:09:05: Error starting packager: Error: Couldn't start project. Please fix the errors and restart the project.
at C:\xdl\src\Project.js:1329:11
at Generator.next (<anonymous>)
at step (C:\reactJs-projects\my-first-native-app\node_modules\xdl\build\Project.js:1735:191)
at C:\reactJs-projects\my-first-native-app\node_modules\xdl\build\Project.js:1735:361
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-first-native-app#0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-first-native-app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Tried fixing with downgrading npm to version 4 as recommended all over that version 5 has bugs.
npm i -g npm#4
I have also tried latest npm but neither of them worked.
When I run npm install on my project directory, instead of installing/updating my packages, it is giving following error
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I see all dependencies downloaded in node_modules though
Any suggestion on what I have missed?
What I also noticed is when the app is created (using create-react-native-app my-first-native-app) it also added following error in console
yarn install v0.21.3
[1/4] Resolving packages...
warning jest-expo > jest > jest-cli > istanbul-api > istanbul-lib-hook#1.2.1: 1.2.0 should have been a major version bump
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/react-native-web-maps/-/react-native-web-maps-
0.1.0.tgz: invalid tar file".
info If you think this is a bug, please open a bug report with the information provided in "C:\\reactJs-projects
\\MyNewNativeApp\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Failed to install
Thank You!

Reinstall your NPM/YARN and get the newest version of React Native i have this problem too

after create your project with
$ create-react-native-app my-first-native-app
after you should enter your project folder :
$ cd my-first-native-app
and then open emulator or connect to tour device and run with
$ npm start
or
$ react-native run-android
pay attention you had installed android-SDK and android-JDK and your emulator is running

After trying different versions, I ended up using yarn and it worked on first instance. If anyone struggles with similar problem, then I would recommend using Yarn and move on. One can switch back to npm after the app is created. This is very common issue reported and for many developers it works with certain version.

Create new project using command : npx react-native init ProjectName
Create new project using particular version of react native :
npx react-native init ProjectName --version X.XX.X
After that go to project location
cd ProjectName
Run application on android platform
npx react-native run-android

Related

Error installing sveltekit app after upgrading Node to latest version

I recently upgraded node to the latest version (v16.15.1). After upgrading, I started a new sveltekit site using the following command:
npm init svelte my-app
I CD'd into my-app and ran npm install and get the following error:
npm ERR! code 127
npm ERR! path /Users/henken/Sites/my-app
npm ERR! command failed
npm ERR! command sh -c svelte-kit sync
npm ERR! sh: svelte-kit: command not found
I've created many sveltekit apps using these exact steps without any issues until today after upgrading node. Any suggestions would be much appreciated.
Remove the my-app folder and run:
npm init svelte#latest my-app
The #latest makes sure that npm uses latest version of the create-svelte package.
The version you've got cached locally could be incompatible with the current version of SvelteKit.
Alternative things to try:
Reboot PC (removes environment settings that could point to previous node installation)
Upgrade npm to latest version

Strapi with MongoDB (macOS): error while creating the project with the command "npx create-strapi-app my-project"?

I am trying to create a Strapi application with MongoDB and I am following the docs on the website, but when configuring the connection, I get this error and I am not understanding why.
Error I get everytime (screenshot)
Log's error (screenshot)
Error:
"Connection test failed: Command failed: npm install --prefix /var/folders/gb/519s_wwn1ps0c0skqw7_03140000gn/T/strapi40136a8b0f29 strapi-connector-mongoose#3.5.4
npm ERR! Cannot read property 'spec' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/red/.npm/_logs/2021-04-08T09_37_12_689Z-debug.log"
MongoDB was installed using Brew and is running as a service.
Node version is 14.16.1.
NPM version is 7.8.0.
Never had a problem like this before with any sort of package or similar.
I already tried to: uninstall MongoDB and reinstall it, reinstall Node and npm.
When I run npm install -g npm-reinstall I get this instead and I think it is related to the problem:
Error screenshot
What I need to fix this?
I fixed this issue by changing the registry of npm config.
npm config set registry https://registry.npmjs.org/
I had to downgrade npm to its previous version to avoid this error.
npm install -g npm#6

npm ERR! cb() never called, on windows10 while creating first react project

While creating first react app using command "create-react-app myfirstapp", I got the following errors:
D:\ReactProject>create-react-app myfirstapp
Creating a new React app in D:\ReactProject\myfirstapp.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\intex\AppData\Roaming\npm-cache\_logs\2021-02-19T07_57_36_091Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting myfirstapp/ from D:\ReactProject
Installed ReactJS version is:
D:\ReactProject>create-react-app --version
4.0.2
Installed Node version is:
D:\ReactProject>node -v
v14.15.5
Note: This is first time I am creating ReactJS app on Windows machine, so installed NodeJS first time on this machine and tried to create the react app and got the above errors.
Please let me know your suggestions on fixing these errors.
Also, find attached screenshot of the above.
I tried couple of things, but the following worked for me.
I run this command "npm install --global windows-build-tools" using
Administrative privileges and it worked for me.
I tried on windows 10 just now. I used PowerShell Window. Simple, go to your project directory -> hold the shift button and click the right mouse button -> select 'Open PowerShell window here' -> start in that cmd. It works for me.

Why am I getting error "No valid versions available for undefined" while installing create-react-app

I'm trying to install React through command prompt. NodeJS is already installed.
When I try to run this command:
npm i -g create-react-app
It is displaying error as shown below:
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xyz\AppData\Roaming\npm-cache\_logs\2019-12-10T10_51_39_2222-debug.log
Sometimes this can happen when you are using a private NPM registry / proxy registry and it has corrupted metadata. I've seen this happen with Sonatype Nexus 3 - there were corresponding error messages in the server logs.
Are you sure you have the right Node version? Try updating NodeJS or try running: npx create-react-app my-app
you should check this out issue.
If the problem still exist, please check your versions with this:
npm -v
node -v
For me this error came up because I had a version number that did not exist for a package I wanted.

npm ERR! errno -5

hi i am getting this error when I try typical starter command with react native
react-native init test
returns this error
npm WARN react-native#0.44.0 requires a peer of react#16.0.0-alpha.6 but none was installed.
Setting up new React Native app in /Users/xxxx/ReactNativeProjects/gpss
Installing React...
gpss#0.0.1 /Users/xxxxx/ReactNativeProjects/gpss
└── react#16.0.0-alpha.6
Installing Jest...
npm ERR! code EIO
npm ERR! errno -5
npm ERR! syscall read
npm ERR! EIO: i/o error, read
You could uninstall react-native and then use the following command:
npm install react#reactversion --save.
Note (reactversion) is your desired version you want to have.
You could also just try reinstalling it as:
npm install react --save
Or upgrade with:
npm update react-native
Eventually cleaning the cache worked out fine. Hope this answer solves any user's problem in the future.
I just had the same problem on Windows, using Virtual Studio Code. I uninstalled an unrelated program shortly before the error and I suspect that was the cause. So I restarted my PC and updated Windows and the npm errors were gone. Everything is working and disaster averted.
Try closing background tasks, updating and/or restarting your computer.

Resources