NPM install causes a significant amount of errors in React Native - react-native

This is most likely an issue with npm.
I have a react-native project that worked fine until I ran npm install.
Once I did this, I started to receive a significant amount of errors.
To name a couple:
I received this for multiple pods:
The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1
There were also multiple modules that had missing files.
I was able to revert to a previous version of my node_modules, without running npm install, and there were no issues.
However, when I run npm install, the issue persists.
Wondering if anyone else has experienced this and found a solution.

i believe you may have conflicts with the version of npm you used previously. i am getting different results when using npm#5 and npm#6 to install.

Related

Why does my 'npm install' give so many vulnerabilities?

Everytime I do npm install after cloning a github project OR install packages on my local system for my practice projects, there are always around 20+ vulnerabilities.
But the guys in youtube tutorials always have 0 vulnerabilities.
I even reinstalled npm but it didn't change anything
If you are following an old video, you are likely installing old packages. Therefore it's pretty common to have vulnerabilities.
If you want the warnings to disappear, you can try to remove #version in your packages inside package.json and then run npm i again. Or, as bogdanoff says, run npm update instead.
But be careful: packages may behave differently from the video when updated.

Warning: Invalid version react-native#0.64.2 for expo sdkVersion 43.0.0. Use react-native#0.64.3

I am working on an expo project and everything is working fine, but I began to get a warning message when android is building as
Warning: Invalid version react-native#0.64.2 for expo sdkVersion 43.0.0. Use react-native#0.64.3
The app is still running fine but I don't how to fix this error yet and I want to know if it won't cause an issue later.
I have tried to run npx react-native upgrade 0.64.3 but it didn't work, I got this error
info Fetching diff between v0.64.2 and v0.64.3... error Fetch request
failed with status 404: 404: Not Found. error Failed to fetch diff for
react-native#0.64.3. Maybe it's not released yet?
changing the version of react-native manually in the package.json and run expo install worked for me
I use the expo doctor command it allows diagnose issues with the project.
I would recommend using the expo upgrade command. It upgrades the project packages and config for the given SDK version.
More to find here.
I just faced the same issue. Basically it's telling you should use a higher version of your react-native. I solved it just by updating it to the specified version.
npx react-native upgrade 0.64.3
More info here.
Cheers,
If as in my case one need a specific version of react-native, let's say older because some legacy dependencies in a particular project that for some reason can't be upgrade, then change the version in the package.json won't work.
What worked as the cli suggested is to use:
expo doctor --fix-dependencies
That installed the correct lower version of react-native
To find out actual problems run this command :
expo doctor
To solve all problems regarding package conflicts run this command:
expo doctor --fix-dependencies
Use sudo on Unix based OS if you have permission issue to run those commands.
To solve the error, I used the below command:
npm install react-native-clean-project --save-dev
It is a library that allows us to resolve conflicts.
This library is added to your dependencies.
This handles the problem and if it is not the case add this command:
react-native clean-project-auto

Cannot find module ‘#expo/metro-config’ when trying to start the project with expo cli >= 4.8.0

I recently tried to launch my project on a new computer. I downloaded the source code from its repository and ran npm install to get all the needed packages.
However, when I run npm start or expo start:web, I get the error:
Cannot find module '#expo/metro-config'
I ran npm install #expo/metro-config and the install run without issue, but I still get the “Cannot find module '#expo/metro-config'” error.
The only post I saw regarding this error recommends editing the metro.config.js but I do not use one.
I am on SDK 42, and the project launches fine on my other computer. Any idea what is happening?
FYI, I use to perform this whole operation without any issue until now.
UPDATE:
I ran npm install -g #expo/metro-config and now I get the error Cannot find module 'resolve-from'
So it looks like maybe running npm install -g expo-cli doesn't actually install all the necessary packages? Could it be the issue?
I managed to make it "work" (get other missing packages errors down the line) by reverting to expo-cli 4.7.3. Anything from 4.8.0 and above will cause the error.
Something else is that on a fresh npm install, after running npm install -g expo-cli, if I try to create a project with expo init, I will get the error Error: Cannot find module 'kleur'. Running npm install kleur fix it, but maybe that's also a clue.

npm 7 installed but version 6 is still wanted

I recently updated npm to the latest version (7.1.1) using the following command:
npm i -g npm#7.1.1
It successfully installed npm 7.1.1, but when I check for global outdated packages I get this:
https://i.stack.imgur.com/3JzCS.png
How can I set the wanted version of npm to >7.0 so that I don't get this anymore in the outdated list?
Thank you.
The docs for npm outdated indicate that when running npm outdated --global, the Wanted column "shows the currently-installed version." Since it is not doing that, that would seem to be a bug in npm. Either the Wanted column should display 7.1.1 in your case or else the documentation needs to be updated to reflect the actual behavior. (I've confirmed the same behavior on my own machine, so I don't believe this is a case of user error.) I suggest opening an issue in the npm issue tracker.

react native doesn't recognize project

I've made a fresh clone of a react-native project which is 100% ok and working. Installed react-native-cli, trying to run react-native start in the project dir, but I get Command start unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
I tried to init a fresh project just to test, and it worked fine, I was able to run react native commands there and everything worked.
It's definitely not an issue with my project because other people work on it as well and it's 100% ok and valid. This is some issue with react native or some other lib, I suppose. What could that be?
I'm using mac os sierra and project's react native version is 0.40.0
So, I've resolved this issue finally, and, to whoever it may concern: the problem wasn't with react-native. The problem was with npm. I was using yarn, and had npm 5 installed on my system. Also I had a postinstall script, which called rn-nodeify. rn-nodeify, in turn, on the final stage called npm (not yarn), and since it was npm 5 I was experiencing an npm 5 bug, which wiped out my modules. The bug is described e.g. here. Downgrading to npm 4 solved this issue for me.