簡體   English   中英

Picker 已從 React Native 中移除。 現在可以從“@react-native-picker/picker”安裝和導入它

[英]Picker has been removed from React Native. It can now be installed and imported from '@react-native-picker/picker'

請幫助:!我已經搜索了整個項目,它根本不使用 Picker,但是當我運行 npx react-native run-android 它拋出:

ERROR Invariant Violation: Picker 已從 React Native 中移除。 現在可以從“@react-native-picker/picker”而不是“react-native”安裝和導入它。 請參閱https://github.com/react-native-picker/picker錯誤不變違規:模塊 AppRegistry 不是已注冊的可調用模塊(調用 runApplication)。 錯誤的常見原因是應用程序入口文件路徑不正確。 當 JS 包損壞或加載 React Native 時出現早期初始化錯誤時,也會發生這種情況。

這個人在下面的鏈接中面臨同樣的問題......沒有答案......請幫助......提前謝謝你

Invariant Violation:Picker 已從 React Native 中移除

我安裝了@react-native-picker/picker

這是我的 package.json

  "name": "MYAPP",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "build-android": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.android.js --bundle-output iOS/main.jsbundle --platform 'android' --assets-dest ./  --dev false --reset-cache",
    "test": "jest",
    "test:watch": "npm run test -- --watch",
    "postinstall": "npx jetify",
    "extractLangs": "react-gettext-parser --output messages.pot 'src/**/*.js'"
  },

  "dependencies": {
    "@react-native-community/cli": "^6.3.1",
    "@react-native-community/masked-view": "0.1.11",
    "@react-native-picker/picker": "^2.2.1",
    "axios": "0.24.0",
    "base-64": "1.0.0",
    "date-fns": "2.27.0",
    "gettext.js": "git+https://github.com/freiserg/gettext.js.git",
    "lodash": "4.17.21",
    "react": "17.0.2",
    "react-native": "0.66.3",
    "react-native-device-info": "8.4.8",
    "react-native-eject": "0.1.2",
    "react-native-extended-stylesheet": "0.12.0",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "^2.1.0",
    "react-native-keyboard-aware-scroll-view": "0.9.5",
    "react-native-navigation": "7.24.2",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-splash-screen": "3.3.0",
    "react-native-swipeout": "2.3.6",
    "react-native-swiper": "1.6.0",
    "react-native-vector-icons": "9.0.0",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "7.2.6",
    "redux": "4.1.2",
    "redux-logger": "3.0.6",
    "redux-persist": "6.0.0",
    "redux-thunk": "2.4.1",
    "shitty-qs": "1.0.1",
    "tcomb-form-native": "0.6.20"
  },
  "devDependencies": {
    "babel-eslint": "10.0.1",
    "babel-jest": "27.4.5",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.6",
    "eslint": "8.4.1",
    "eslint-config-airbnb": "19.0.2",
    "eslint-plugin-import": "2.25.3",
    "eslint-plugin-jsx-a11y": "6.5.1",
    "eslint-plugin-react": "7.27.1",
    "jest": "27.4.5",
    "jetifier": "2.0.0",
    "metro-react-native-babel-preset": "^0.66.2",
    "nock": "13.2.1",
    "react-gettext-parser": "1.16.0",
    "react-native-mock": "0.3.1",
    "react-test-renderer": "17.0.2",
    "redux-mock-store": "1.5.4"
  },
  "jest": {
    "preset": "react-native",
    "verbose": true,
    "setupFiles": [
      "<rootDir>/__tests__/mocks/global.js"
    ],
    "testMatch": [
      "**/__tests__/**/*.spec.js?(x)"

官方選擇器已從 react-native 中刪除。 您可以使用社區版。 @react-native-community/picker

刪除節點模塊文件夾,然后在項目目錄的終端上運行yarn install

然后嘗試再次運行該應用程序。

我不確定這會有所幫助,但因為它說當 JS 包損壞或加載 React Native 時出現早期初始化錯誤時也會發生這種情況。 這可能值得一試。

  1. 安裝@react-native-picker/picker
  2. 升級"native-base": "2.15.2"

就我而言, tcomb-form-native導致了這個錯誤,因為它已經多年沒有更新了。 我希望這個 PR 將很快被合並。 https://github.com/gcanti/tcomb-form-native/pull/605

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM