Приложение Cordova React - TypeError [ERR_INVALID_ARG_TYPE]: аргумент «путь» должен иметь тип string. Получил неопределенный - PullRequest
0 голосов
/ 26 марта 2020

Поскольку я перепробовал все, что недавно обнаружил на StackOverflow и аналогичных сайтах (реакции-dev-инструменты, повышение и понижение, переустановку и т. Д.), Я собираюсь открыть свой собственный поток.

Так вот в чем проблема: я работаю над приложением React, созданным на Cordova. Я могу запустить приложение через npm start. Мой коллега использует тот же репозиторий и не имеет проблем.

Но каждый раз, когда я пытаюсь добавить платформу android, я сталкиваюсь с этим сообщением об ошибке:

The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:117:11)
    at Object.join (path.js:1039:7)
    at ConfigKeeper_get [as get] (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigKeeper.js:45:26)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:346:51
    at Array.forEach (<anonymous>)
    at is_conflicting (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:339:17)
    at PlatformMunger.add_config_changes (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:190:33)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:112:32
    at _fulfilled (/Users/rmeier/lv-app/node_modules/q/q.js:854:54)
    at /Users/rmeier/lv-app/node_modules/q/q.js:883:30

Вот cordova info:

cordova-lib@9.0.1 with:
  cordova-common@3.2.1
  cordova-create@2.0.0
  cordova-fetch@2.0.1
  cordova-serve@3.0.0

Environment: 
  OS: darwin
  Node: v12.16.1
  npm: 6.13.4

Plugins:
  cordova-plugin-androidx
  cordova-plugin-androidx-adapter
  cordova-plugin-file
  cordova-plugin-firebasex
  cordova-plugin-network-information
  cordova-plugin-splashscreen
  cordova-plugin-statusbar
  cordova-plugin-whitelist
  cordova-plugin-x-socialsharing
  cordova-sqlite-ext
  es6-promise-plugin

config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="censored" version="1.0.10" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android" >
    <name>censored</name>
    <description>
        censored
    </description>
    <author email="censored" href="censored">
        censored
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="BackgroundColor" value="0x36642a"/>
    <platform name="android">
        <allow-intent href="market:*" />
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
        <config-file platform="ios" parent="CFBundleDevelopmentRegion" overwrite="true">
            <string>Germany</string>
        </config-file>

        <icon src="res/android/hdpi.png" />
        <icon src="res/android/ldpi.png" density="ldpi" />
        <icon src="res/android/mdpi.png" density="mdpi" />
        <icon src="res/android/hdpi.png" density="hdpi" />
        <icon src="res/android/xhdpi.png" density="xhdpi" />
        <icon src="res/android/xxhdpi.png" density="xxhdpi" />
        <icon src="res/android/xxxhdpi.png" density="xxxhdpi" />

        <splash density="port-ldpi" src="res/android/splash-port-ldpi.png"/>
        <splash density="port-mdpi" src="res/android/splash-port-mdpi.png"/>
        <splash density="port-hdpi" src="res/android/splash-port-hdpi.png"/>
        <splash density="port-xhdpi" src="res/android/splash-port-xhdpi.png"/>
        <splash density="port-xxhdpi" src="res/android/splash-port-xxhdpi.png"/>
        <splash density="port-xxxhdpi" src="res/android/splash-port-xxxhdpi.png"/>

        <splash density="land-ldpi" src="res/android/splash-land-ldpi.png"/>
        <splash density="land-mdpi" src="res/android/splash-land-mdpi.png"/>
        <splash density="land-hdpi" src="res/android/splash-land-hdpi.png"/>
        <splash density="land-xhdpi" src="res/android/splash-land-xhdpi.png"/>
        <splash density="land-xxhdpi" src="res/android/splash-land-xxhdpi.png"/>
        <splash density="land-xxxhdpi" src="res/android/splash-land-xxxhdpi.png"/>

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
        </config-file>
        <resource-file src="res/android/mdpi_mono.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
        <resource-file src="res/android/hdpi_mono.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
        <resource-file src="res/android/xhdpi_mono.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
        <resource-file src="res/android/xxhdpi_mono.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
        <resource-file src="res/android/xxxhdpi_mono.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />
        <resource-file src="res/android/xxxhdpi_large.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon_large.png" />


    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="StatusBarBackgroundColor" value="#36642a" />

        <!-- iOS 8.0+ -->
              <icon src="res/ios/180.png"/>
              <!-- iPhone 6 Plus  -->
              <icon src="res/ios/180.png" width="180" height="180" />
              <!-- iOS 7.0+ -->
              <!-- iPhone / iPod Touch  -->
              <icon src="res/ios/60.png" width="60" height="60" />
              <icon src="res/ios/120.png" width="120" height="120" />
              <!-- iPad -->
              <icon src="res/ios/76.png" width="76" height="76" />
              <icon src="res/ios/152.png" width="152" height="152" />
              <!-- iOS 6.1 -->
              <!-- Spotlight Icon -->
              <icon src="res/ios/40.png" width="40" height="40" />
              <icon src="res/ios/80.png" width="80" height="80" />
              <!-- iPhone / iPod Touch -->
              <icon src="res/ios/57.png" width="57" height="57" />
              <icon src="res/ios/114.png" width="114" height="114" />
              <!-- iPad -->
              <icon src="res/ios/72.png" width="72" height="72" />
              <icon src="res/ios/144.png" width="144" height="144" />
              <icon src="res/ios/167.png" height="167" width="167" />
              <!-- iPhone Spotlight and Settings Icon -->
              <icon src="res/ios/29.png" width="29" height="29" />
              <icon src="res/ios/58.png" width="58" height="58" />
              <!-- iPad Spotlight and Settings Icon -->
              <icon src="res/ios/50.png" width="50" height="50" />
              <icon src="res/ios/100.png" width="100" height="100" />
              <icon src="res/ios/1024.png" height="1024" width="1024" />
              <!--  Splash Screen   -->
              <splash src="res/ios/Default@2x~iphone~anyany.png"/>
              <splash src="res/ios/Default@2x~iphone~comany.png"/>
              <splash src="res/ios/Default@3x~iphone~anyany.png"/>
              <splash src="res/ios/Default@3x~iphone~comany.png"/>
              <splash src="res/ios/Default@2x~ipad~anyany.png"/>
              <splash src="res/ios/Default@2x~ipad~comany.png"/>
    </platform>
</widget>

package.json:

{
  "name": "censored",
  "homepage": "./",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@babel/core": "7.4.3",
    "@svgr/webpack": "4.1.0",
    "@typescript-eslint/eslint-plugin": "1.6.0",
    "@typescript-eslint/parser": "1.6.0",
    "babel-eslint": "10.0.1",
    "babel-jest": "^24.9.0",
    "babel-loader": "8.0.5",
    "babel-plugin-named-asset-import": "^0.3.4",
    "babel-preset-react-app": "^9.0.2",
    "bootstrap": "^4.3.1",
    "camelcase": "^5.2.0",
    "case-sensitive-paths-webpack-plugin": "2.2.0",
    "cordova": "^9.0.0",
    "cordova-android": "^8.1.0",
    "cordova-ios": "^5.0.1",
    "cordova-plugin-androidx": "1.0.2",
    "cordova-plugin-androidx-adapter": "1.1.0",
    "cordova-plugin-file": "6.0.1",
    "cordova-plugin-firebasex": "6.1.0",
    "cordova-plugin-network-information": "2.0.1",
    "cordova-plugin-splashscreen": "5.0.3",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-x-socialsharing": "^5.6.2",
    "cordova-sqlite-ext": "3.0.0",
    "css-loader": "2.1.1",
    "dotenv": "6.2.0",
    "dotenv-expand": "4.2.0",
    "es6-promise-plugin": "4.2.2",
    "eslint": "^5.16.0",
    "eslint-config-react-app": "^4.0.1",
    "eslint-loader": "2.1.2",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.16.0",
    "eslint-plugin-jsx-a11y": "6.2.1",
    "eslint-plugin-react": "7.12.4",
    "eslint-plugin-react-hooks": "^1.7.0",
    "file-loader": "3.0.1",
    "fs-extra": "7.0.1",
    "html-webpack-plugin": "4.0.0-beta.5",
    "identity-obj-proxy": "3.0.0",
    "is-wsl": "^1.1.0",
    "jest": "24.7.1",
    "jest-environment-jsdom-fourteen": "0.1.0",
    "jest-resolve": "24.7.1",
    "jest-watch-typeahead": "0.3.0",
    "mini-css-extract-plugin": "0.5.0",
    "onsenui": "^2.10.10",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "pnp-webpack-plugin": "1.2.1",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "7.0.1",
    "postcss-preset-env": "6.6.0",
    "postcss-safe-parser": "4.0.1",
    "react": "^16.11.0",
    "react-app-polyfill": "^1.0.4",
    "react-bootstrap": "^1.0.0-beta.14",
    "react-datepicker": "^2.9.6",
    "react-dev-utils": "^9.1.0",
    "react-dom": "^16.11.0",
    "react-onsenui": "^1.11.2",
    "resolve": "1.10.0",
    "sass-loader": "7.1.0",
    "semver": "6.0.0",
    "style-loader": "0.23.1",
    "terser-webpack-plugin": "1.2.3",
    "ts-pnp": "1.1.2",
    "typescript": "^3.6.4",
    "url-loader": "1.1.2",
    "webpack": "4.29.6",
    "webpack-dev-server": "3.2.1",
    "webpack-manifest-plugin": "2.0.4",
    "workbox-webpack-plugin": "4.2.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!src/**/*.d.ts"
    ],
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "setupFilesAfterEnv": [],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
      "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jest-environment-jsdom-fourteen",
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "modulePaths": [],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ],
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "devDependencies": {
    "cordova-plugin-whitelist": "^1.3.4"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-file": {},
      "cordova-plugin-network-information": {},
      "cordova-sqlite-ext": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+",
        "PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to function properly."
      },
      "cordova-plugin-statusbar": {},
      "cordova-plugin-firebasex": {
        "FIREBASE_ANALYTICS_COLLECTION_ENABLED": "false",
        "FIREBASE_PERFORMANCE_COLLECTION_ENABLED": "false",
        "FIREBASE_CRASHLYTICS_COLLECTION_ENABLED": "false",
        "ANDROID_ICON_ACCENT": "#FF00FFFF",
        "ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION": "17.0.0",
        "ANDROID_FIREBASE_CORE_VERSION": "17.0.0",
        "ANDROID_FIREBASE_MESSAGING_VERSION": "19.0.0",
        "ANDROID_FIREBASE_CONFIG_VERSION": "18.0.0",
        "ANDROID_FIREBASE_PERF_VERSION": "18.0.0",
        "ANDROID_FIREBASE_AUTH_VERSION": "18.0.0",
        "ANDROID_CRASHLYTICS_VERSION": "2.10.1",
        "ANDROID_CRASHLYTICS_NDK_VERSION": "2.1.0",
        "ANDROID_SHORTCUTBADGER_VERSION": "1.1.22"
      }
    },
    "platforms": [
      "ios"
    ]
  }
}

...