0

在我从 Expo SDK 40 升级到 SDK 43 之后,npm start我得到了这个错误"Unable to resolve module @unimodules/core"

然后我检查了我的package.json,我没有安装这个包。

任何帮助将不胜感激。

完整的错误堆栈跟踪:

Warning: https://github.com/expo/react-native/archive/sdk-43.0.0.tar.gz is not a valid version. Version must be in the form of sdk-x.y.z. Please update your package.json file.
info Launching Dev Tools...
iOS Bundling failed 4235ms
Unable to resolve module @unimodules/core from /Users/user/path/to/project/node_modules/expo-linking/build/Linking.js: @unimodules/core could not be found within the project or in these directories:
  node_modules
  ../../../../node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | import { Platform, UnavailabilityError } from '@unimodules/core';
    |                                                ^
  2 | import Constants from 'expo-constants';
  3 | import invariant from 'invariant';
  4 | import qs from 'qs';

这是我的 package.json:

{
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "test": "jest"
    },
    "jest": {
        "preset": "jest-expo"
    },
    "dependencies": {
        "@react-native-async-storage/async-storage": "^1.13.3",
        "@react-native-community/art": "^1.2.0",
        "@react-native-community/datetimepicker": "3.0.4",
        "@react-native-community/masked-view": "0.1.10",
        "@react-native-community/netinfo": "5.9.7",
        "@react-native-community/push-notification-ios": "^1.2.2",
        "@react-native-community/slider": "3.0.3",
        "@react-navigation/native": "^5.1.4",
        "aws-amplify": "^3.3.1",
        "aws-amplify-react-native": "^4.2.6",
        "axios": "^0.19.2",
        "expo": "^43.0.0",
        "expo-app-loading": "^1.0.1",
        "expo-barcode-scanner": "~9.1.0",
        "expo-camera": "~9.1.0",
        "expo-constants": "~9.3.3",
        "expo-font": "~8.4.0",
        "expo-linking": "~2.0.1",
        "expo-mail-composer": "~9.0.0",
        "expo-notifications": "~0.8.2",
        "expo-permissions": "~10.0.0",
        "expo-secure-store": "~9.3.0",
        "expo-sqlite": "~8.5.0",
        "expo-updates": "~0.4.1",
        "expo-web-browser": "~8.6.0",
        "file-saver": "^2.0.2",
        "jsbarcode": "^3.11.3",
        "link": "^0.1.5",
        "qs": "^6.9.4",
        "react": "16.13.1",
        "react-dom": "16.13.1",
        "react-native": "https://github.com/expo/react-native/archive/sdk-43.0.0.tar.gz",
        "react-native-barcode-expo": "^1.1.1",
        "react-native-elements": "^3.2.0",
        "react-native-fs": "^2.16.6",
        "react-native-gesture-handler": "~1.8.0",
        "react-native-modal": "^11.5.6",
        "react-native-modal-datetime-picker": "^8.6.0",
        "react-native-paper": "^3.10.1",
        "react-native-push-notification": "^3.5.2",
        "react-native-reanimated": "~1.13.0",
        "react-native-router-flux": "^4.2.0",
        "react-native-safe-area-context": "3.1.9",
        "react-native-screens": "~2.15.2",
        "react-native-snap-carousel": "^3.9.1",
        "react-native-svg": "12.1.0",
        "react-native-web": "~0.13.12",
        "react-navigation-animated-switch": "^0.6.4",
        "react-navigation-drawer": "^2.4.11",
        "react-navigation-header-buttons": "^3.0.5",
        "react-router-dom": "^6.0.0-alpha.3"
    },
    "devDependencies": {
        "@babel/core": "^7.12.9",
        "@babel/runtime": "^7.9.2",
        "@react-native-community/eslint-config": "^0.0.7",
        "babel-jest": "^25.1.0",
        "babel-preset-expo": "8.5.1",
        "eslint": "^6.8.0",
        "expo-cli": "^4.12.8",
        "jest": "^25.5.4",
        "jest-expo": "~43.0.1",
        "metro-react-native-babel-preset": "^0.59.0",
        "react-test-renderer": "^16.13.1"
    },
    "private": true
}
4

3 回答 3

0

我在我的项目中包含了“@unimodules/core”:“~7.2.0”,现在它可以工作了。然后我可以升级到 43 和 44 博览会版本。

于 2022-02-22T20:51:08.657 回答
0

我试图将我的项目从 42 升级到 44,但我遇到了同样的问题。这似乎是另一个包含 unimodules、expo-constants 的库的问题。我试图删除它,但很多其他库依赖它。所以,我无法解决它。

于 2022-02-19T22:40:10.963 回答
0

都修好了!问题是 Expo 将 SDK 43 中的 react-native-unimodules 替换为 expo。https://github.com/expo/fyi/blob/main/expo-modules-migration.md

脚步:

  1. 删除 node_modules
  2. 删除 package-lock.json
  3. 运行 expo upgrade 43 (以确保软件包版本全部对齐)
  4. 运行 expo start -c
于 2022-01-19T05:38:28.940 回答