React native react native找不到存在的节点_模块。这可能只在我使用“纱线”工作区时发生

React native react native找不到存在的节点_模块。这可能只在我使用“纱线”工作区时发生,react-native,yarnpkg,monorepo,React Native,Yarnpkg,Monorepo,为了添加它,我运行了以下命令: yarn workspace mobile add react-native-webview 我已经仔细查看了下面错误指定的node_模块文件夹,并且react native webview显然就在那里。但是,始终会抛出此错误吗?我甚至在红色错误屏幕上写下了当模块显示为缺失但实际存在时的步骤 Error: Unable to resolve module `react-native-webview` from `index.js`: react-native-w

为了添加它,我运行了以下命令:

yarn workspace mobile add react-native-webview
我已经仔细查看了下面错误指定的node_模块文件夹,并且react native webview显然就在那里。但是,始终会抛出此错误吗?我甚至在红色错误屏幕上写下了当模块显示为缺失但实际存在时的步骤

Error: Unable to resolve module `react-native-webview` from `index.js`: react-native-webview could not be found within the project or in these directories:
  ../../node_modules
  /Users/kurnalsaini/Documents/test-mono/packages/mobile/node_modules

我是否应该修改metro配置文件或其他配置文件以使其正常工作?因为对我来说,它告诉我它在正确的文件夹中查找,但仍然说它不存在,这令人难以置信。

尝试设置metro配置以监视错误中显示的目录中的节点模块,你的metro.config.js应该如下所示: 常量路径=要求(“路径”)

const watchFolders=[
//包目录的相对路径
路径解析(uuu dirname+“/…),
resolve(_dirname+“/../../../node_modules”),
];
module.exports={
重置缓存:对,
变压器:{
getTransformOptions:async()=>({
转换:{
支持:false,
内部要求:错误,
},
}),
},
监视文件夹,
};
检查。您需要更新metro的监视文件夹。