cli icon indicating copy to clipboard operation
cli copied to clipboard

react-native run-ios and react-native run-android commands fail

Open ZoltanSzokodi opened this issue 3 years ago • 1 comments

Hi,

when I try to run react-native run-ios or react-native run-android from my project folder in VSCode I get the following error:

error Cannot read properties of undefined (reading 'configurations').
TypeError: Cannot read properties of undefined (reading 'configurations')
    at Object.dependencyConfig (/Users/Desktop/app/node_modules/@react-native-community/cli-platform-ios/build/config/index.js:102:37)
    at /Users/.nvm/versions/node/v16.16.0/lib/node_modules/@react-native-community/cli/node_modules/@react-native-community/cli-config/build/loadConfig.js:47:61
    at Array.reduce (<anonymous>)
    at getDependencyConfig (/Users/.nvm/versions/node/v16.16.0/lib/node_modules/@react-native-community/cli/node_modules/@react-native-community/cli-config/build/loadConfig.js:44:51)
    at Object.get @eva-design/eva [as @eva-design/eva] (/Users/.nvm/versions/node/v16.16.0/lib/node_modules/@react-native-community/cli/node_modules/@react-native-community/cli-config/build/loadConfig.js:99:18)
    at warnAboutManuallyLinkedLibs (/Users/Desktop/app/node_modules/@react-native-community/cli-platform-ios/build/link/warnAboutManuallyLinkedLibs.js:39:43)
    at Object.runIOS [as func] (/Users/Desktop/app/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:104:44)
    at Command.handleAction (/Users/.nvm/versions/node/v16.16.0/lib/node_modules/@react-native-community/cli/build/index.js:192:23)
    at Command.listener (/Users/.nvm/versions/node/v16.16.0/lib/node_modules/@react-native-community/cli/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:527:28)
info Run CLI with --verbose flag for more details.

However if I start the app in XCode it builds successfully. After some research I found the modifying the node_modules/@react-native-community/cli-platform-ios/build/config/index.js fixes the problem:

function dependencyConfig(folder, userConfig) {
// const configurations = userConfig.configurations || [];
    let configurations="";
    const baseConfig = projectConfig(folder, userConfig);
...

(source: https://stackoverflow.com/questions/72479193/error-cannot-read-properties-of-undefined-reading-configurations-typeerror)

However this is super sketchy and I'd rather not patch the package. Any ideas what could be the problem here?

My package.json:

{
  "name": "projectName",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
  },
  "dependencies": {
    "@eva-design/eva": "^2.1.0",
    "@react-navigation/native": "^6.0.11",
    "@ui-kitten/components": "5.1.2",
    "@ui-kitten/eva-icons": "5.1.2",
    "@ui-kitten/metro-config": "5.1.2",
    "react": "17.0.1",
    "react-native": "0.64.1",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "^3.15.0",
    "react-native-svg": "^12.1.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@trivago/prettier-plugin-sort-imports": "^3.3.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.64.5",
    "@types/react-test-renderer": "^16.9.2",
    "@typescript-eslint/eslint-plugin": "^5.33.0",
    "@typescript-eslint/parser": "^5.33.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.14.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsdoc": "^39.3.6",
    "eslint-plugin-prefer-arrow": "^1.2.3",
    "eslint-plugin-react": "^7.30.1",
    "eslint-plugin-unicorn": "^43.0.2",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "17.0.1",
    "typescript": "~4.3.5"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}

ZoltanSzokodi avatar Aug 14 '22 16:08 ZoltanSzokodi

Hi @ZoltanSzokodi . Thanks for reporting! Unfortunately I wasn't able to reproduce this issue, tried with freshly created app ("react-native": "0.69.3") Could you try to update the app and try again?

adamTrz avatar Aug 18 '22 12:08 adamTrz

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar Nov 24 '22 03:11 github-actions[bot]

Currently facing the same issue however I get the error when doing pod install. Did you find a solution for this?

I also tried the

function dependencyConfig(folder, userConfig) { // const configurations = userConfig.configurations || []; let configurations=""; const baseConfig = projectConfig(folder, userConfig); ...

fix but this breaks autolinking.

SocialAnxty avatar Nov 29 '22 22:11 SocialAnxty

This may not solve this particular corner-case, but it solves a similar error message. Use react-native 0.68.x if using the macos and windows plugins together. I was able to repro on Windows if the macos plugin was installed with defaults because it was mixing different react-native versions with the windows plugin. The mac plugin may need to be updated to 0.70.x.

microsoft/react-native-macos#1613

skull-squadron avatar Jan 02 '23 01:01 skull-squadron

I had the same issue. Turns out it was just a compatibility issue. Just execute yarn list --pattern @react-native-community/cli or npm list @react-native-community/cli to see what version you're on and what version you should be on. I had to downgrade to fix the problem.

Roggenbrotium avatar Feb 15 '23 08:02 Roggenbrotium

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar May 17 '23 03:05 github-actions[bot]