react-native-navigation
react-native-navigation copied to clipboard
React Native 0.73 `npx rnn-link` doesn't work
What happened?
starting from rn73 *.java
files was convened to *.kt
so auto-linking doesn't work properly
npx rnn-link
/tmp/Rn73/node_modules/react-native-navigation/autolink/postlink/path.js:10
exports.rootGradle = mainApplicationJava.replace(/android\/app\/.*\.java/, 'android/build.gradle');
^
TypeError: Cannot read properties of undefined (reading 'replace')
at Object.<anonymous> (/Users/davydnarbutovich/tmp/Rn73/node_modules/react-native-navigation/autolink/postlink/path.js:10:42)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/Users/davydnarbutovich/tmp/Rn73/node_modules/react-native-navigation/autolink/postlink/applicationLinker.js:2:12)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
What was the expected behaviour?
no js error, *.kt
files supported out of the box
Was it tested on latest react-native-navigation?
- [X] I have tested this issue on the latest react-native-navigation release and it still reproduces.
Help us reproduce this issue!
No response
In what environment did this happen?
React Native Navigation version: 7.37.2 React Native version: 0.73 Has Fabric (React Native's new rendering system) enabled: (yes/no) Node version: 18 Device model: Android version:
+1
Mesmo problema
+1
The issue is that the following line in path.js assumes that mainApplication
has the java
extension, however it's now a kotlin file, which is why mainApplicationJava
is undefined.
I was able to get around this issue by changing this line...
var mainApplicationJava = glob.sync('**/MainApplication.java', ignoreFolders)[0];
to the following:
var mainApplicationJava = glob.sync('**/MainApplication.{java,kt}', ignoreFolders)[0];
This way the glob.sync func matches both file extensions.
+1
Same here
+1
is this issue has been solved ?
i still have this issue as well
All, please track https://github.com/wix/react-native-navigation/issues/7834 for the official RN73 support 🙏🏻
Hey guys, FYI the similar bug is back / regressed, apologies for appending to this issue. Note, I am using yarn
= 4.4.0
and working on the React Native 0.74.5
project. Please take a look and apply a new patch when able 🙏
And I tried using npx rnn-link
and script failed, same error as original poster.
node = 22.5.1
yarn = 4.4.0
Error output in terminal
/private/var/www/rndemoapp0745/node_modules/react-native-navigation/autolink/postlink/path.js:10
exports.rootGradle = mainApplicationJava.replace(/android\/app\/.*\.java/, 'android/build.gradle');
Dependency versions installed (with yarn
)
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.5",
"react-native-navigation": "^7.40.1"
}
Screenshots
Temporary solution test Applied solution from https://github.com/wix/react-native-navigation/issues/7821#issuecomment-1865390682 and issue resolved.
To change the mainApplicationJava
line, at line in path.js
var mainApplicationJava = glob.sync('**/MainApplication.{java,kt}', ignoreFolders)[0];
Thanks a bunch @jtich!