我在构建反应本机应用程序时收到以下错误。@react-native-community/masked-view
and @react-navigation\stack
是最新的,但不确定为什么在构建时没有解决这个包。
error: Error: While trying to resolve module `@react-native-community/masked-view` from file `C:\..\..\node_
modules\@react-navigation\stack\src\views\MaskedViewNative.tsx`, the package `C:\..\..\node_modules\@react-n
ative-community\masked-view\package.json` was successfully found. However, this package itself specifies a `main` module
field that could not be resolved (`C:\..\..\node_modules\@react-native-community\masked-view\index.js`. Indeed, none of these files exist:
my package.json
{
"name": "appname",
"version": "0.0.1",
"private": true,
"scripts": {
..
},
"dependencies": {
"@react-native-community/async-storage": "^1.11.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-firebase/app": "^8.4.6",
"@react-native-firebase/auth": "^9.3.1",
"@react-native-firebase/firestore": "^7.8.7",
"@react-native-firebase/functions": "^7.4.9",
"@react-native-firebase/storage": "^7.4.10",
"@react-navigation/bottom-tabs": "5.10.2",
"@react-navigation/drawer": "5.10.2",
"@react-navigation/material-top-tabs": "5.3.2",
"@react-navigation/native": "5.8.2",
"@react-navigation/stack": "5.11.1",
"@reduxjs/toolkit": "^1.4.0",
"axios": "^0.19.2",
"lodash": "^4.17.19",
"moment": "^2.27.0",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-animatable": "^1.3.3",
"react-native-fast-image": "^8.3.2",
"react-native-gesture-handler": "^1.7.0",
"react-native-global-props": "^1.1.5",
"react-native-keyboard-aware-scroll-view": "^0.9.2",
"react-native-paper": "^4.0.1",
"react-native-reanimated": "^1.10.1",
"react-native-safe-area-context": "^3.1.1",
"react-native-screens": "^2.9.0",
"react-native-spinkit": "^1.5.0",
"react-native-vector-icons": "^7.0.0",
"react-redux": "^7.2.1"
},
"devDependencies": {
...
},
"jest": {
"preset": "react-native"
}
}
更新和临时解决方案:
我已尝试卸载@react-native-community/masked-view
几次。
我尝试删除节点模块文件夹,使用以下命令清除缓存npm cache clean --force, react-native start --reset-cache
但到目前为止没有任何效果。
然后我意识到@react-native-community/masked-view
软件包安装时缺少 index.js 文件。
我从另一个项目复制了 js 文件夹和 index.js 文件@react-native-community/masked-view
项目开始建设。
我不确定为什么安装本身缺少该文件夹和索引文件。
非常感谢有关此问题的任何帮助。