react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.32k stars 897 forks source link

error index.js: Cannot read properties of undefined (reading 'match'). #2357

Closed nicolaturcoep closed 2 months ago

nicolaturcoep commented 4 months ago

error index.js: Cannot read properties of undefined (reading 'match'). TypeError: Cannot read properties of undefined (reading 'match') at countLines (C:\Lavoro\GitHub\ePublic\AppNuova\LaMiaCitta\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro\src\lib\countLines.js:17:23) at transformJS (C:\Lavoro\GitHub\ePublic\AppNuova\LaMiaCitta\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro-transform-worker\src\index.js:332:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async transformJSWithBabel (C:\Lavoro\GitHub\ePublic\AppNuova\LaMiaCitta\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro-transform-worker\src\index.js:408:10) at async Object.transform (C:\Lavoro\GitHub\ePublic\AppNuova\LaMiaCitta\node_modules\@react-native-community\cli-plugin-metro\node_modules\metro-transform-worker\src\index.js:569:12) info Run CLI with --verbose flag for more details.

Package.Json:

{ "name": "it.epublic.comapp", "version": "2.1.0", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native --openssl-legacy-provider start", "test": "jest", "check-dependencies": "rnx-dep-check", "fix-dependencies": "rnx-dep-check --write", "clean": "cd android && gradlew clean && cd..", "doctor": "npx react-native doctor", "depcheck": "npx depcheck", "adb": "adb devices", "setnodeopenssl": "set NODE_OPTIONS=--openssl-legacy-provider", "setopt": "set NODE_ENV=production&& webpack --mode production && set NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development&& webpack --mode development --watch", "cleanmodules": "npm rm -rf node_modules && npm install", "buildapkdebug": "cd android && gradlew clean assembleDebug && cd..", "buildapkrelease": "npm i -g react-native-cli && react-native bundle --entry-file index.js --platform android --dev false --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/ && cd android && gradlew assembleRelease && cd ..", "buildaab": "npm i -g react-native-cli && react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/ && cd android && gradlew clean bundleRelease && cd.. && start .\OpenBundleFolder", "obf": "start .\OpenBundleFolder", "aabdebug": "npx react-native build-android --mode=debug", "aabrelease": "npx react-native build-android --mode=release", "apkdebug": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && cd android && ./gradlew assembleDebug && cd ..", "bundletoolapk": "bundletool build-apks --bundle=/LaMiaCitta/android/app/build/outputs/bundle/app-debug.aab --output=/LaMiaCitta/android/app/build/outputs/bundle/my_app.apks" }, "dependencies": { "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-community/cli": "^6.4.0", "@react-navigation/bottom-tabs": "^6.3.2", "@react-navigation/drawer": "^6.4.1", "@react-navigation/material-bottom-tabs": "^6.2.2", "@react-navigation/material-top-tabs": "^6.2.2", "@react-navigation/native": "^6.0.8", "@react-navigation/native-stack": "^6.6.1", "@react-navigation/stack": "^6.2.0", "accordion-collapse-react-native": "^1.1.0", "pushy-react-native": "^1.0.36", "react": "18.2.0", "react-native": "0.73.6", "react-native-background-fetch": "^4.2.4", "react-native-background-geolocation": "^4.16.0", "react-native-bootsplash": "^5.5.2", "react-native-calendars": "^1.1292.0", "react-native-draggable": "^3.3.0", "react-native-gesture-handler": "^2.6.0", "react-native-image-modal": "^1.0.16", "react-native-image-zoom-viewer": "^3.0.1", "react-native-in-app-review": "^3.3.3", "react-native-linear-gradient": "^2.6.2", "react-native-maps": "^0.31.1", "react-native-mime-types": "^2.3.0", "react-native-modal": "^13.0.0", "react-native-pager-view": "^5.4.15", "react-native-paper": "^4.12.4", "react-native-permissions": "^3.6.0", "react-native-reanimated": "^3.8.1", "react-native-render-html": "^6.1.0", "react-native-safe-area-context": "^4.4.1", "react-native-screens": "^3.18.2", "react-native-tab-view": "^3.1.1", "react-native-vector-icons": "^9.2.0", "react-native-webview": "^13.8.4", "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.73.21", "@react-native/eslint-config": "0.73.2", "@react-native/metro-config": "0.73.5", "@react-native/typescript-config": "0.73.1", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" } }

error occurred while executing npm run buildapkrelease

szymonrybczak commented 4 months ago

hey @nicolaturcoep! I see that your buildapkrelease script is installing globally react-native-cli which is not allowed and is not suggested for already few years, that can cause very strange scenarios like one with your error.

You should use npx react-native to invoke any commands, let me know if removing react-native-cli from global package and changing usage for npx react-native fixes the issues. If no, I'd appreciate a demo where it's possible to reproduce your issue.