react-native - React-native:node_modules\@react-native-community\masked-view 中缺少 index.js 文件
问题描述
我在构建 react-native 应用程序时遇到以下错误。
@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
了几次。我试过删除节点模块文件夹,使用类似命令清除缓存,npm cache clean --force, react-native start --reset-cache
但到目前为止没有任何效果。
然后我意识到@react-native-community/masked-view
安装包中缺少 index.js 文件。
我从另一个项目复制了 js 文件夹和 index.js 文件,@react-native-community/masked-view
项目开始构建。
我不确定为什么安装本身缺少此文件夹和索引文件。
非常感谢您对此问题的任何帮助。
解决方案
推荐阅读
- c# - Assets/Script/Scoreboard.cs(33,2):错误 CS1525:意外符号“{”
- r - 使用离散数据自定义图例
- node.js - MongoDB $lookup 只返回一个文档
- android - 具有受限密钥的应用程序中的谷歌地图不起作用
- javascript - 检查频道名称
- python - 在方波上检测 egde
- c++ - DRD 在 std::mutex::lock 上报告“冲突加载”错误
- java - Javafx:从文件中读取并使用 .split 方法拆分结果
- python - 为什么 Python 在 print() 输出之前将异常打印到控制台
- c - 写入的数字少于从文件中读取的数字