React Native `native-base`,但是,此包本身指定了一个无法解析的`main`模块字段

brgchamk  于 2023-04-07  发布在  React
关注(0)|答案(2)|浏览(144)

错误:当尝试从文件C:\Users\byambadorj\Desktop\LoginEx\src\LoginScreen.js解析模块native-base时,成功找到了包C:\Users\byambadorj\Desktop\LoginEx\node_modules\native-base\package.json。但是,此包本身指定了无法解析的main模块字段(C:\Users\byambadorj\Desktop\LoginEx\node_modules\native-base\src\index。实际上,这些文件都不存在C:\Users\byambadorj\Desktop\LoginEx\node_modules\native-base\src\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

  • C:\Users\byambadorj\Desktop\LoginEx\node_modules\native-base\src\index\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)at DependencyGraph.resolveDependency(C:\Users\byambadorj\Desktop\LoginEx\node_modules\metro\src\node-hast\DependencyGraph.js:311:17)......

这是我的package.json

{
      "name": "LoginEx",
      "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 ."
      },
      "dependencies": {
        "@react-navigation/native": "^6.0.6",
        "native-base": "^3.2.2",
        "react": "17.0.2",
        "react-native": "0.66.4",
        "react-native-safe-area-context": "^3.3.2",
        "react-native-screens": "^3.10.1",
        "react-native-size-matters": "^0.4.0"
      },
      "devDependencies": {
        "@babel/core": "7.16.7",
        "@babel/runtime": "7.16.7",
        "@react-native-community/eslint-config": "2.0.0",
        "babel-jest": "26.6.3",
        "eslint": "7.14.0",
        "jest": "26.6.3",
        "metro-react-native-babel-preset": "0.66.2",
        "react-test-renderer": "17.0.2"
      },
      "jest": {
        "preset": "react-native"
      }
    }
oknrviil

oknrviil1#

尝试停止地铁和重新启动它清除缓存。

npm start --reset-cache
dojqjjoe

dojqjjoe2#

尝试停止地铁和重新启动它清除缓存

npm start --reset-cache

如果你使用的是mac,它将无法工作.尝试在mac上

sudo npm start --reset-cache

相关问题