无法找到模块'反应原生'

问题描述 投票:0回答:2

跟随this article设置流量,eslint和预先准确(但使用纱线而不是npm,如果这很重要)。我要么在'react-native'上找到模块未找到错误(在安装flow-typed之后就会消失)但是无论哪种方式,本机中名为“react-native-implementation.js”的本地文件都存在错误几乎每一行都来自“不能精细模块'不变','警告','ActivityIndi​​cator'”。

即使在安装'flow-typed'并且从App.js添加存根错误消失但该应用程序无法在Metro服务器上抛出此错误

error: bundling failed: Error: Cannot find module 'babel-preset-react-native' from 'C:\PropertyFinder'
- If you want to resolve "react-native", use "module:react-native"
    at Function.module.exports [as sync] (C:\PropertyFinder\node_modules\resolve\lib\sync.js:58:15)
    at resolveStandardizedName (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:101:31)
    at resolvePreset (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:58:10)
    at loadPreset (C:\PropertyFinder\node_modules\@babel\core\lib\config\files\plugins.js:77:20)
    at createDescriptor (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:154:9)
    at items.map (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (C:\PropertyFinder\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)

这不仅来自我的旧项目,而且也是复制的项目,我需要更好的intellisense流程。

javascript react-native eslint flowtype
2个回答
0
投票

我已经修复了错误,这是我做的步骤(可以有改进):

1.截至目前,flow的bin版本是0.97.0,react-native生成^0.92.0所以在.flowconfig中我将其更改为^ 0.97.0 2.Now在你的项目的根目录创建一个文件flowLibs.js(or anything really).在.flowconfig下的[。 libs]粘贴./flowLibs.js并粘贴

<PROJECT_ROOT>/node_modules/.*   
<PROJECT_ROOT>/flowLibs.js

在[ignore]标签下。 3.现在刚刚在上面创建的flowLibs.js文件粘贴

declare module "react-native" { declare module.exports: any; }

或者如果你对另一个模块有问题,那么用你的模块替换react-native。这也修复了错误无法解决模块'react-native'

注意:您不需要安装flow-bin

原因是反应本机包含flow-type如果你在vs代码上安装了流语言支持扩展,那么最新版本的flow-bin客户端已经存在,即截至目前为止0.97.0


-1
投票

针对npm问题的标准修复

rm -rm node_modules

npm cache clean -f

npm和

您是yarn用户,因此请尝试删除旧的node_modules文件夹并重新运行安装。

© www.soinside.com 2019 - 2024. All rights reserved.