react-native-rename icon indicating copy to clipboard operation
react-native-rename copied to clipboard

TypeError: Cannot read properties of undefined (reading 'replace')

Open joegoodall1 opened this issue 1 year ago • 9 comments

/ios/TestChange RENAMED
mv: no such file or directory: /Users/Joe/OutOfTheBoxAgain/ios/OutOfTheBoxAgain-tvOS
Ignore above error if this file doesn't exist
mv: no such file or directory: /Users/JoeOutOfTheBoxAgain/ios/OutOfTheBoxAgain-tvOSTests
Ignore above error if this file doesn't exist
/ios/TestChange.xcodeproj RENAMED
mv: no such file or directory: /Users/JoeOutOfTheBoxAgain/ios/TestChange.xcodeproj/xcshareddata/xcschemes/OutOfTheBoxAgain-tvOS.xcscheme
Ignore above error if this file doesn't exist
/ios/TestChange.xcodeproj/xcshareddata/xcschemes/TestChange.xcscheme RENAMED
/ios/TestChangeTests RENAMED
/ios/TestChangeTests/TestChangeTests.m RENAMED
/ios/TestChange.xcworkspace RENAMED
mv: no such file or directory: /Users/Joe/OutOfTheBoxAgain/ios/TestChange/OutOfTheBoxAgain.entitlements
Ignore above error if this file doesn't exist
mv: no such file or directory: /Users/Joe/OutOfTheBoxAgain/ios/OutOfTheBoxAgain-Bridging-Header.h
Ignore above error if this file doesn't exist
/android/app/src/main/res/values/strings.xml MODIFIED
/index.js MODIFIED
/ios/TestChange/Info.plist MODIFIED
/package.json MODIFIED
/app.json MODIFIED
/ios/TestChange.xcodeproj/project.pbxproj MODIFIED
/ios/TestChange.xcworkspace/contents.xcworkspacedata MODIFIED
/ios/TestChange.xcodeproj/xcshareddata/xcschemes/TestChange.xcscheme MODIFIED
/android/settings.gradle MODIFIED
/ios/TestChangeTests/TestChangeTests.m MODIFIED
/ios/Podfile MODIFIED
/app.json MODIFIED
/Users/Joe/.npm/_npx/d6cd7bd98532808c/node_modules/react-native-rename/lib/index.js:228
              var newJavaPath = javaFileBase + '/' + newBundleID.replace(/\./g, '/');
                                                                 ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at /Users/Joe.npm/_npx/d6cd7bd98532808c/node_modules/react-native-rename/lib/index.js:228:66
    at new Promise (<anonymous>)
    at /Users/Joe/.npm/_npx/d6cd7bd98532808c/node_modules/react-native-rename/lib/index.js:225:20
    at Array.map (<anonymous>)
    at /Users/Joe/.npm/_npx/d6cd7bd98532808c/node_modules/react-native-rename/lib/index.js:224:38

Getting the above error on a newly created React Native project. Any idea why?

joegoodall1 avatar May 24 '23 13:05 joegoodall1

i am facing the same problem.

any solution for the same got the solution @joegoodall1 pls follow the link : https://github.com/junedomingo/react-native-rename/issues/185#issuecomment-1396120033

VikasReactNative avatar May 26 '23 04:05 VikasReactNative

hi @joegoodall1 , may i know your env info Environment (please complete the following information):

  • operating system:
  • npm version:
  • node version:
  • react-native-rename version:
  • react-native version:

junedomingo avatar Jun 12 '23 07:06 junedomingo

Hi @junedomingo I am also facing the same issue and I have added my environment details

  • operating system: MacOS Ventura v13.4
  • npm version: 9.6.5
  • node version: v20.0.0
  • react-native-rename version: 3.2.13 (tried with npx)
  • react-native version: 0.71.7

Update:

🥹🥹🥹

I was running the npx react-native-rename "Travel App" -b "com.junedomingo.travelapp" inside the Android folder instead of the root folder. The command works once I moved to root.

rsathishtechit avatar Jun 15 '23 17:06 rsathishtechit

INFOPLIST_KEY_CFBundleDisplayName = "${t}";)),s&&(c=c.replace(/PRODUCT_BUNDLE_IDENTIFIER = "(.*)"/g,PRODUCT_BUNDLE_IDENTIFIER = "${s}"),c=c.replace(/PRODUCT_BUNDLE_IDENTIFIER = (.*)/g,PRODUCT_BUNDLE_IDENTIFIER = "${s}";)),c)},{files:"ios/*/Base.lproj/LaunchScreen.xib",from:[new RegExp(\b${a}\b,"g"),new RegExp(\b${e}\b,"g")],to:i},{files:"ios/*/LaunchScreen.storyboard",from:[new RegExp(text="${a}","g"),new RegExp(text="${e}","g")],to:text="${i}"}]},q1=({currentName:e,newName:t,newBundleIDAsPath:r})=>{let n=nr(t).toLowerCase();return[{files:"android/settings.gradle",from:[/rootProject.name = "(.*)"/g,/rootProject.name = '(.*)'/g],to:rootProject.name = '${t}'},{files:[android/app/src/main/java/${r}/MainActivity.java],from:["${e}"],to:"${t}"},{files:"android/.idea/.name",from:e,to:t},{files:android/app/src/main/java/${r}/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java,from:/SoLoader\.loadLibrary\("(.*)"\)/g,to:SoLoader.loadLibrary("${n}_appmodules")},{files:"android/app/src/main/jni/CMakeLists.txt",from:/project\((.*)\)/g,to:project(${n}_appmodules)},{files:"android/app/build.gradle",from:/targets \"(.*)_appmodules\"/,to:targets "${n}_appmodules"},{files:"android/app/src/main/jni/Android.mk",from:/LOCAL_MODULE \:\= (.*)_appmodules/,to:LOCAL_MODULE := ${n}_appmodules},{files:"android/.idea/workspace.xml",from:[/<module name="(.*)\.app\.main" \/>/,new RegExp(e,"g")],to:[,t]}]},$1=({currentBundleID:e,newBundleID:t,currentBundleIDAsPath:r,newBundleIDAsPath:n})=>[{files:["android/app/_BUCK","android/app/BUCK","android/app/build.gradle",android/app/src/debug/java/${n}/ReactNativeFlipper.java,android/app/src/release/java/${n}/ReactNativeFlipper.java,android/app/src/main/java/${n}/MainActivity.java,android/app/src/main/java/${n}/MainApplication.java],from:new RegExp(${e},"g"),to:t},{files:[android/app/src/main/java/${n}/newarchitecture/MainApplicationReactNativeHost.java,android/app/src/main/java/${n}/newarchitecture/components/MainComponentsRegistry.java,android/app/src/main/java/${n}/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java],from:new RegExp(e,"g"),to:t},{files:["android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h","android/app/src/main/jni/MainComponentsRegistry.h"],from:[new RegExp(L${r},"g"),new RegExp(L${e},"g")],to:L${n}},{files:"android/.idea/workspace.xml",from:new RegExp(${r},"g"),to:n},{files:"android/app/src/main/AndroidManifest.xml",from:new RegExp(${e},"g"),to:t}],j1=({currentName:e,newName:t,currentPathContentStr:r,newPathContentStr:n,appJsonName:s,appJsonDisplayName:i,packageJsonName:a,newAndroidBundleID:o,newIosBundleID:c})=>{let l=n.replace(/\s/g,"").toLowerCase();return[{files:["index.js","index.ios.js","index.android.js"],from:[new RegExp(\b${e}\b,"g"),new RegExp(\b'${e}'\b,"g")],to:t},{files:"package.json",from:[new RegExp(${a},"gi"),new RegExp(${r},"gi")],to:l},{files:"app.json",from:[new RegExp(${s},"gi"),new RegExp(${i},"gi"),/\"scheme\"\: \"(.*)\"/,/\"package\"\: \"(.*)\"/,/\"bundleIdentifier\"\: \"(.*)\"/,/\"name\"\: \"(.*)\"/,/\"slug\"\: \"(.*)\"/],to:[t,t,"scheme": "${l}","package": "${o}","bundleIdentifier": "${c}","name": "${t}","slug": "${t}"]}]};Y1.config();var ge=process.env.DEV_APP_PATH||process.cwd(),Q1=200,yO=30,CO=/[^\p{L}\p{N}]+/gu,K1=3,SO=/^[a-zA-Z]{1}[a-zA-Z0-9\._]{1,}$/,xO=/^[a-zA-Z]{1}[a-zA-Z0-9\.\-]{1,}$/,vO=(e,t,r="es")=>${e} ${t}${e!==1?r:""},z1=e=>new Promise(t=>setTimeout(t,e)),An=e=>Ce.default.relative(ge,e),nr=e=>e.replace(CO,""),Cn=e=>e.replace(/\./g,"/"),NO=e=>(0,Da.decode)(e,{level:"xml"}),Oa=e=>(0,Da.encode)(e,{mode:"nonAscii",level:"xml",numeric:"hexadecimal"}),yn=process.platform==="win32"?G1():e=>e,J1=Ce.default.join(ge,P1),Z1=()=>{let e=on(yn(Ce.default.join(ge,La)))[0].replace("AppDelegate.h","Info.plist");_t.default.existsSync(e)&&_t.default.existsSync(J1)||(console.log('Directory should be created using "react-native init".'),process.exit())},eT=()=>{nt.default.cd(ge),nt.default.exec("git rev-parse --is-inside-work-tree",{silent:!0}).code===0||(console.log("This is not a git repository"),process.exit())},tT=()=>{nt.default.cd(ge),nt.default.exec("git status --porcelain",{silent:!0}).stdout===""||(console.log(The directory is not clean. There are changes that have not been committed to the Git repository.

TypeError: Cannot read properties of undefined (reading 'replace') at Z1 (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:53:3888) at vn. (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:66:662) at vn.r [as _actionHandler] (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:13:483) at /Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:16:2843 at vn._chainOrCall (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:16:1455) at vn._parseCommand (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:16:2819) at vn.parseAsync (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:13:4074) at Object. (/Users/karthickramesh/Desktop/zeequant/zeequant-analytics/node_modules/react-native-rename/lib/index.js:66:1508) at Module._compile (node:internal/modules/cjs/loader:1256:14)

I'm facing this issue how to resolve using node latest "engines": { "node": "18.16.1", "npm": "9.7.2" },

techiekarthick avatar Jul 05 '23 05:07 techiekarthick

i have same issue

TypeError: Cannot read properties of null (reading '1') at aT (C:\Users\Admin\AppData\Local\npm-cache_npx\d6cd7bd98532808c\node_modules\react-native-rename\lib\index.js:57:910) at vn. (C:\Users\Admin\AppData\Local\npm-cache_npx\d6cd7bd98532808c\node_modules\react-native-rename\lib\index.js:66:875)

zkteco-home avatar Jul 08 '23 12:07 zkteco-home

Same issue here try to use
npx [email protected]

MShokry avatar Jul 23 '23 09:07 MShokry

Experiencing the same behavior.

npx react-native-rename@latest "My app" --iosBundleID "com.client.app" --androidBundleID "com.client"

TypeError: Cannot read properties of undefined (reading 'replace') at hT (/Users/user/.npm/_npx/7bbe2151e410de60/node_modules/react-native-rename/lib/index.js:57:3165) at vn.<anonymous> (/Users/user/.npm/_npx/7bbe2151e410de60/node_modules/react-native-rename/lib/index.js:66:1023) at async vn.parseAsync (/Users/user/.npm/_npx/7bbe2151e410de60/node_modules/react-native-rename/lib/index.js:13:4063)

Environment

[skip envinfo]

OS: macOS 13.4.1
Node: 20.6.1
Yarn: 1.22.19
npm: 9.8.1
Watchman: 2023.09.04.00
CocoaPods: 1.12.1
Xcode: 14.3.1/14E300c
Java: Not Found
Ruby: 3.2.2
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Osmon11 avatar Oct 29 '23 18:10 Osmon11

So I was able to solve this, What I did was install the react-native-rename directly in the root folder "yarn add react-native-rename"

Davidon4 avatar Nov 03 '23 18:11 Davidon4

Make sure you're running this command in your root folder of the project and not inside any other folder

mannyuiux avatar Nov 08 '23 21:11 mannyuiux