junedomingo / react-native-rename

Rename react-native app with just one command
MIT License
2.63k stars 261 forks source link

Cannot read properties of undefined (reading 'replace') #185

Closed evanstern closed 1 year ago

evanstern commented 1 year ago

Describe the bug Running npx react-native-rename "New Name" results in an error after the ios/XXX/Info.plist reports itself as UPDATED.

The error is

TypeError: Cannot read properties of undefined (reading 'replace')
   at Cn (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/react-native-rename/lib/index.js:50:3569)
    at vn.<anonymous> (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/react-native-rename/lib/index.js:61:1031)
    at async vn.parseAsync (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/react-native-rename/lib/index.js:10:4063)

To Reproduce Steps to reproduce the behavior:

  1. Create a new project with npx react-native init
  2. Enter the new project directory
  3. Attempt to rename the project using npx react-native-rename "New Name"
  4. Updates occur until after Info.plist and then an error is displayed

Expected behavior It should not throw an error

Environment (please complete the following information):

shaquibimdad commented 1 year ago

I am facing the same type error

Some infos: operating system: Arch Linux npm version: 8.15.0 node version: v16.17.1 react-native-rename version: 3.2.7 react-native version: 0.71.0

pataiadam commented 1 year ago

I also encountered the same error as the one described in the issue. I found the cause of the error by looking at the source:

var currentBundleID = $data('manifest').attr('package');

It appears that the app is looking for the 'package' attribute in the manifest file. So, I opened android/app/src/main/AndroidManifest.xml and saw that it was not defined.

💡 Solution: I just had to define package attr. with the current/old package name and then run the script My manifest file's first 3 lines look like this after update:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.oldappname"
>
junedomingo commented 1 year ago

Fixed in v3.2.8, cheers!