React native not working in npm 5.3.0 - react-native

I am new to React Native. I installed it by:
npm install -g create-react-native-app
When I tried
create-react-native-app MyProject
it shows that npm 5 is not supported yet and I need to downgrade npm.
If I will downgrade npm, will it affect other projects?
Is there any other way without downgrade npm?

You can downgrade your version of npm with npm install -g npm#4
Then, you can run create-react-native-app MyProject

You can download and use yarn instead of npm. If you change your npm version you have to use it with the other projects too. There are tools out there t let you use different versions of npm I think but I can't suggest anything because I never used them before.
I suggest you to use yarn.

Related

create-react-app not working not after upgrading npm and nodejs

I upgraded npm and nodejs to 6.14.4 and 12.16.3 resp. Getting below error while creating react app using create-react-app.
According to readme:
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.
So resolved the problem using command:
npx create-react-app contactmanager

Cant Install expo cli

I'm trying to install Expo CLI for React Native
The latest version of Node js also installed
in command prompt, I typed npm install expo-cli --global
I'm getting error
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[..................] \ fetchMetadata: WARN deprecated request#2.88.2: request has been deprecated, see https://github.com
I also checked the GitHub issues/3142 but not found any solution
I was having the same issue install expo-cli with npm it gives WARN of request#2.88.2 deprecation, then what I did, simply install
npm install -g yarn
and after that
yarn global add expo-cli
and now it's successfully installed expo-cli, and I have the latest version of expo-cli as of today.
$ expo --version
3.15.4
It is not an error, it is just a warning so you should not worry. Everything seems fine. You can check your expo-cli installation within below command:
$ expo --version
2.21.2
By the way you don't have to install expo-cli at all. You can use npx expo init to create a expo project.
I had the same problem and it turned out my version of NodeJs was not supported. The documentation states that you need Node.js LTS release or greater.
This is the output when I attempted to install expo-cli then ran expo --version
Output:
ERROR: Node.js v12.10.0 is no longer supported.
expo-cli supports following Node.js versions:
* >=10.13.0 <11.0.0 (Maintenance LTS)
* >=12.13.0 <13.0.0 (Active LTS)
* >=14.0.0 <15.0.0 (Current Release)
I solved it by updating nodejs and reinstalled expo-cli with npm i --global expo-cli and it worked.

Expo cli update not happening

I am trying to upgrade expo-cli from 2.11 to 2.18 but npm i -g expo-cli#latest still points to the old version.
when I typed expo-cli -V it resulted:
2.11 ...so naturally npm i -g expo-cli#latest will grab the latest version and install it but still expo-cli -v is still pointing to the old version.
I remember installing packages in bash level is a no go operation.
these are some images to put it all into context:
Update: Removed Nodes modules as suggested in the first answer, and that lead to npm removal both expo and expo-cli are not found with the command where
For mac users (linux should be very similar):
Find your expo-cli version:
which expo-cli
For me it yielded:
/Users/username/.config/yarn/global/node_modules/.bin/expo-cli
Remove this outdated version:
rm -rf /Users/username/.config/yarn/global/node_modules/.bin/expo-cli
Check that you are using the latest version:
expo-cli --version
Updating expo-cli globally can be a right pain. To those experiencing this frustration, use yarn
yarn global add expo-cli
it will give you far fewer headaches
On MacOS (Linux should be very similar):
Find the location of the expo-cli version:
which expo-cli
You would probably get:
/usr/local/bin/expo-cli
Remove this outdated version by using:
rm -rf /usr/local/bin/expo-cli
Then install the latest version:
npm install -g expo-cli
After that, check that you are using the latest version:
expo-cli --version
If you're like me, and none of this stuff worked, maybe my solution will help.
My problem is that I switched from NPM, to Yarn at some point, and I had global packages in both systems, which was giving me a bunch of trouble.
Step 1: Make sure you don't have expo-cli in global npm
npm list-g
Step 2: If it is in global npm, uninstall it
npm uninstall --global expo-cli
Step 3: Install it fresh with yarn
yarn global add expo-cli
Step 4: Stop using npm for global packages (or at least, only use one system)
edit: spelling
If you are using a Mac, these 2 commands will do the tricks
1)which expo to locate expo in your Mac which will give you this "/usr/local/bin/expo"
2) "cd /usr/local/bin/"
3)-rm expo
4)-rm expo-cli
the hole system was behaving oddly!, npm should've been installed with node but it was nowhere to be found.
I had to remove node and reinstall it again, then I had to install expo-cli again and all errors went away.
When npm does not work in an easy way, --force it!
npm install -g expo-cli --force
Update to the latest version of Expo CLI:
npm i -g expo-cli. expo-cli#4.7.2 or greater is required.
Update to the latest version of EAS CLI if you use it:
npm i -g eas-cli.
Run expo upgrade in your project directory.
Reference: https://docs.expo.dev/workflow/upgrading-expo-sdk-walkthrough/
there is more than a reason for not updating the expo-cli.
reason 1 - you maybe installed expo-cli using yarn and after a while you need to update and using npm npm install -g expo-cli it will update but maybe when you run expo its point to that yarn version so to resolve this you need to run yarn global remove expo-cli.
reason 2 - it might you have two versions of expo-cli one its global version and one inside your project folder/path, so even you upgrade expo-cli globally, your project still point to the first class version which is in your project folder. to resolve this you need to uninstall expo-cli which exists in your project folder to point to the global version and you can do this using this command npm uninstall expo-cli notice without -g.
reson 3 - sometimes you need to clean npm cache. if nothing works for you above try to uninstall expo-cli using npm uninstall -g expo-cli and then run this command npm cache clean --force then install expo-cli again npm install -g expo-cli.
expo-cli --version
npm uninstall expo-cli
npm install -g expo-cli
expo-cli --version
if cannot, you can update manually
check path
npm bin -g
change "node_modules" folder or remove
C:\Users{username}.npm-global\node_modules
npm install -g expo-cli
copy\past expo-cli folder
from C:\Users{username}.npm-global\node_modules\expo-cli
to C:\Users{username}\AppData\Roaming\npm\node_modules\expo-cli
expo-cli --version

Where and How should I add AsyncStorage with React Native 0.59?

I just upgraded to react-native 0.59.0-rc.3 and I'm getting a warning about AsyncStorage that will be removed from react-native and added to #react-native-community/async-storage.
But in the #react-native-community/async-storage it only says how to link it, but not how to install it
e.g npm install some_package
Where Should I install it from?
npm install react-native-community and just import it from that?
npm install #react-native-community/async-storage?
As it states on the repo
# Install
$ yarn add #react-native-community/async-storage
Usually if a dependency is available with yarn it is available with npm
However, if you are using npm instead of yarn you can install it with
npm i #react-native-community/async-storage
yarn and npm are both package managers. Choose one and stick with it.
To see if a package is available for npm you can search on https://www.npmjs.com
As you can see from the below link that it is on npm and can be installed using npm i.
https://www.npmjs.com/package/#react-native-community/async-storage
The NPM package is #react-native-community/async-storage.
Have a look at the NPM page for it

npm packages installed from command line not appearing in packages.json dependencies for React-Native project

I have a React-Native project and I'm trying to install certain npm modules in my project.
However, when I try to do so from the command line, the packages says it is installed correctly, but it is not appearing in the packages.json dependency.
For instance, I installed react-relay using npm install react-relay.
The package looks to have installed correctly. But I check my packages.json and react-relay is not in there.
I have tried react-native link, and the packages are not coming up.
What is going on?
you would need to use the "save" option: npm install react-relay --save
You need to add save option
npm install react-relay --save
or
npm i react-relay --s
To remove node module from package.json file
npm uninstall react-relay --save
Here is documentation for npm install