I use NVM to manage node versions for a number of react-native projects. I have found that when starting a project from the terminal, metro will start using whatever the alias'd default node version is, and not the version specified by nvm use.
So, prior to starting up a particular project i will ensure that i run both (for example):
nvm alias default v18.18.0
nvm use v18.18.0
If i need to swap back to some other version, i will do the same thing:
nvm alias default v16.16.0
nvm use v16.16.0
I use nvm list to verify my settings are correct.
I use NVM to manage node versions for a number of react-native projects. I have found that when starting a project from the terminal, metro will start using whatever the alias'd default node version is, and not the version specified by nvm use.
So, prior to starting up a particular project i will ensure that i run both (for example):
nvm alias default v18.18.0
nvm use v18.18.0
If i need to swap back to some other version, i will do the same thing:
nvm alias default v16.16.0
nvm use v16.16.0
I use nvm list to verify my settings are correct.
In order to use a specific version of node in your react native project, you can set it inside of the project.ext.react config at the root level of your app/build.gradle file as follows:
project.ext.react = [
...
nodeExecutableAndArgs: ['/path/to/your/node'],
...
]
for example, using nvm in a mac, you could use something similar to:
project.ext.react = [
...
nodeExecutableAndArgs: ['/Users/your.user/.nvm/versions/node/v16.13.0/bin/node'],
...
]
Videos
I have started learning react native CLI and working on a simple to-do app using firebase. I finally made it work, but after sometime getting syjtax errors on random library files, and got to know it may be because of react-native node versions incompatibility. Currently I'm using below version: could you please help and let me which versions I have to use for firestore based react native cli app.
PS D:\ReactNative\TodoFirestoreApp> react-native --version react-native-cli: 2.0.1 react-native: 0.78.2 PS D:\ReactNative\TodoFirestoreApp> node --version v22.14.0 PS D:\ReactNative\TodoFirestoreApp>
I want to get an app started, but my Node.js version is apparently "too recent." Can I make it work, or will I have to downgrade?
I went through the same problem. I did the following:
Uninstall NVM:
rm -rf $NVM_DIR ~/.npm ~/.bower
Install NVM again (check the latest version here):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
Install the node version that you want to use:
nvm install 20
Use it:
nvm use 20
Profit! :)
===============================================================
Extra:
In order to make it work with the project itself, what I did was:
Go to your android folder inside your project:
cd android/
Stop gradlew demon:
./gradlew --stop
Go up to your root project folder:
cd ..
Run react native's start command:
npx react-native start
In another tab, run the emulator (check if your node version is correct by running node --version):
npx react-native run-android --list-devices
Select your emulator and voilá!
try to run node --version with out listing through nvm
or try to uninstall nvm and node then download and install latest version of node without nvm and try again
this could be an issue with nvm
» npm install nodejs-mobile-react-native
» npm install react-native