React-native:index.js文件在节点_modules\@React-native community\masked视图中丢失
我在构建react本机应用程序时遇到以下错误。React-native:index.js文件在节点_modules\@React-native community\masked视图中丢失,react-native,react-navigation,React Native,React Navigation,我在构建react本机应用程序时遇到以下错误。 @react-native-community/masked-view和@react-navigation\stack是最新的,但不确定为什么在生成时未解析此包 error: Error: While trying to resolve module `@react-native-community/masked-view` from file `C:\..\..\node_ modules\@react-navigation\stack\src\
@react-native-community/masked-view
和@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
。
我尝试过删除node modules文件夹,使用npm cache clean--force,react native start--reset cache等命令清除缓存,但到目前为止没有任何效果
然后我意识到,@react native community/masked view
安装中缺少index.js文件
我从另一个项目中复制了js文件夹和index.js文件,用于@react native community/masked view
,项目开始构建
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"
}
}
我不知道为什么这个文件夹和索引文件在安装过程中丢失了
非常感谢您在这个问题上提供的任何帮助。我建议您先安装
warn
,然后使用react native start--reset cache
重新启动应用程序,因为您的所有依赖项都与我的匹配。我现在已经做了几次了。还尝试清除缓存/删除节点模块,但没有效果far@satya164sourceExts未添加到我的metro.config.js文件中,我添加并重置了缓存。。问题依然存在。我在这里粘贴了metro.config.js文件。如果您需要查看任何其他文件,请告诉我。如果我删除@react navigation/stack并停止使用stacknavigator,则项目运行正常。所以我认为与@react导航配置有关