菜鸟教程小白 发表于 2022-12-13 15:21:15

ios - 运行 react native ios应用程序时找不到文件依赖错误


                                            <p><p>所以我想使用 npm 安装一个依赖项,即 <code>react-native-router-flux</code>,但由于与 react 和 react-native 的兼容版本,它无法正常工作,所以它是打破我的项目应用程序。所以我把它从 <code>package.json</code> 文件中删除了。</p>

<p>尝试通过以下方式删除它:</p>

<p><code>npm uninstall --save react-native-router-flux</code></p>

<p>甚至尝试从 package.json 文件中手动删除它,但由于某种原因,现在看来我的整个项目都因此而损坏。
现在每当我做 <code>npm start</code></p>

<p>这是在我的终端中显示的内容:</p>

<pre><code>error: bundling: Error: ENOENT: no such file or directory, open &#39;/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native-router-flux/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js&#39;
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at Module._readSourceCode (/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native/packager/src/node-haste/Module.js:200:29)
    at Module._getCacheProps (/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native/packager/src/node-haste/Module.js:420:29)
    at Module._readFromTransformCache (/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native/packager/src/node-haste/Module.js:376:29)
    at Module.readCached (/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native/packager/src/node-haste/Module.js:363:25)
    at Promise.resolve.then (/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:167:29)
    at process._tickCallback (internal/process/next_tick.js:103:7)
Bundling `index.ios.js`94.0% (2941/3033)
</code></pre>

<p>我尝试了 rm -rf/node_modules 100 次和 npm install 又 100 次,这一直失败和失败,我不明白在哪里试图访问该文件!如果它被删除! </p>

<p>这是我的 package.json 现在:</p>

<pre><code>{
&#34;name&#34;: &#34;myapp&#34;,
&#34;version&#34;: &#34;0.0.1&#34;,
&#34;private&#34;: true,
&#34;scripts&#34;: {
    &#34;start&#34;: &#34;node node_modules/react-native/local-cli/cli.js start&#34;,
    &#34;test&#34;: &#34;jest&#34;
},
&#34;dependencies&#34;: {
    &#34;moment&#34;: &#34;^2.18.1&#34;,
    &#34;native-base&#34;: &#34;^2.1.3&#34;,
    &#34;react&#34;: &#34;16.0.0-alpha.6&#34;,
    &#34;react-native&#34;: &#34;0.44.0&#34;,
    &#34;react-native-flags&#34;: &#34;^1.0.0&#34;
},
&#34;devDependencies&#34;: {
    &#34;babel-jest&#34;: &#34;19.0.0&#34;,
    &#34;babel-preset-react-native&#34;: &#34;1.9.1&#34;,
    &#34;jest&#34;: &#34;19.0.2&#34;,
    &#34;react-test-renderer&#34;: &#34;16.0.0-alpha.6&#34;
},
&#34;jest&#34;: {
    &#34;preset&#34;: &#34;react-native&#34;
}
}
</code></pre>

<p>还会针对版本和其他内容抛出警告:</p>

<pre><code>npm WARN [email protected] requires a peer of react@&gt;=15.1.0 but none was installed.
npm WARN @shoutem/[email protected] requires a peer of react@^15.0.0 but none was installed.
npm WARN [email protected] requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.
</code></pre>

<p>这是针对本地基础依赖项引发的:</p>

<pre><code> UNMET PEER DEPENDENCY react@^0.13.0 || ^0.14.0 || ^15.0.0
</code></pre>

<p>谁能帮帮我?这让我发疯,现在已经为此“战斗”了几个小时,但我无法继续使用我的应用程序。</p>

<p>提前致谢。</p>

<hr/>

<p><strong></strong></p><h1><strong>编辑:</strong></h1>
在为 react、react-native 和 native-base 更改了一些版本之后。仍然有警告,并且看起来打包程序正在尝试访问 react-native-route-flux 中的 react-native 文件。<p></p>

<p>1) 这是我当前的 package.json </p>

<pre><code>{
&#34;name&#34;: &#34;myapp&#34;,
&#34;version&#34;: &#34;0.0.1&#34;,
&#34;private&#34;: true,
&#34;scripts&#34;: {
    &#34;start&#34;: &#34;node node_modules/react-native/local-cli/cli.js start&#34;,
    &#34;test&#34;: &#34;jest&#34;
},
&#34;dependencies&#34;: {
    &#34;moment&#34;: &#34;^2.18.1&#34;,
    &#34;native-base&#34;: &#34;^2.1.3&#34;,
    &#34;react&#34;: &#34;16.0.0-alpha.3&#34;,
    &#34;react-native&#34;: &#34;^0.43.0&#34;,
    &#34;react-native-flags&#34;: &#34;^1.0.0&#34;
},
&#34;devDependencies&#34;: {
    &#34;babel-jest&#34;: &#34;19.0.0&#34;,
    &#34;babel-preset-react-native&#34;: &#34;1.9.1&#34;,
    &#34;jest&#34;: &#34;19.0.2&#34;,
    &#34;react-test-renderer&#34;: &#34;16.0.0-alpha.6&#34;
},
&#34;jest&#34;: {
    &#34;preset&#34;: &#34;react-native&#34;
}
}
</code></pre>

<p>2) 这些是警告:</p>

<pre><code>npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of react@&gt;=15.1.0 but none was installed.
npm WARN @shoutem/[email protected] requires a peer of react@^15.0.0 but none was installed.
npm WARN [email protected] requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.
npm WARN [email protected] requires a peer of react@^16.0.0-alpha.6 but none was installed.
</code></pre>

<p>还会在原生基础上引发一些 UNMET PEER DEPENDENCY:</p>

<pre><code>├─┬ [email protected]
│ ├─┬ @shoutem/[email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── UNMET PEER DEPENDENCY react@^15.0.0
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── UNMET PEER DEPENDENCY react@^0.13.0 || ^0.14.0 || ^15.0.0
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ └── [email protected]
├─┬ UNMET PEER DEPENDENCY [email protected]
</code></pre>

<p>并且在控制台中运行时,从 XCode 中抛出模拟器中的红屏错误:</p>

<p><code>没有为关键窗口设置维度</code></p>

<p>看起来是 <a href="https://github.com/aksonov/react-native-router-flux/issues/1832" rel="noreferrer noopener nofollow">known issue</a>根据他的github。但是该死的,我不再想要 react-native-router-flux,我什至在我的 package.json 中都没有它,也没有安装它,仍然会造成麻烦,这种依赖是一种病毒。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>每当您遇到这种情况时,请冷静一下,想想在安装核心第三方时所有其他第三方都安装了什么。我在玩 <code>react-native-router-flux</code> 时遇到了类似的问题,它的稳定版本是 <code>v3.38.0</code>。</p>

<p>从上面的问题看来 <code>@shoutem/[email protected]</code> 和 <code>[email protected]</code> 带有 <code>react-native -router-flux</code> 库。而另一个包,即 <code>native-base</code> 与 <code>react@>=15.1.0</code></p> 兼容

<p>所以我得出结论,从 Node 模块中删除 <code>@shoutem</code> 和 <code>react-static-container</code>。如果仍然存在错误,那么我该死的肯定错误是由于本地基础造成的。从项目中完全移除 <code>native base</code> 并等待 <code>native base</code> 更新到最新版本的 <code>react</code>。</p>

<p>尝试以上方法并分享进展,因为这也可以帮助其他人。</p>

<p>注意 1:当您在安装软件包时看到警告时,请不要忽略这些警告,因为它们可能会破坏某些软件包的功能。</p>

<p>使用 <code>npm install [email protected]</code> 更新软件包,其中 x.y 是您要安装的版本号。</p>

<p>注意 2:安装包 <code>yarn</code> 是首选。 </p>

<p>以下是使用 <code>react-native-router-flux</code> 更新或安装的依赖项:</p>

<pre><code>&#34;dependencies&#34;: {
    &#34;lodash.isequal&#34;: &#34;^4.5.0&#34;,
    &#34;react&#34;: &#34;^15.4.2&#34;,
    &#34;react-addons-pure-render-mixin&#34;: &#34;^15.4.2&#34;,
    &#34;react-dom&#34;: &#34;^15.4.2&#34;,
    &#34;react-native&#34;: &#34;^0.41.2&#34;,
    &#34;react-native-experimental-navigation&#34;: &#34;0.26.x&#34;,
    &#34;react-native-tabs&#34;: &#34;^1.0.9&#34;,
    &#34;react-static-container&#34;: &#34;1.0.1&#34;
},
</code></pre>

<p>如您所见,<code>react-static-container</code> 是从 <code>react-native-router-flux</code> 继承的,其他错误是由于 <code>native-base</code>,请参阅 <code>native-base</code> 提供的以下依赖项。</p>

<pre><code>&#34;dependencies&#34;: {
    &#34;@shoutem/animation&#34;: &#34;^0.8.9&#34;,
    &#34;native-base-shoutem-theme&#34;: &#34;0.1.3&#34;,
    &#34;blueimp-md5&#34;: &#34;^2.5.0&#34;,
    &#34;clamp&#34;: &#34;^1.0.1&#34;,
    &#34;color&#34;: &#34;~0.11.1&#34;,
    &#34;fs-extra&#34;: &#34;^2.0.0&#34;,
    &#34;lodash&#34;: &#34;~4.11.1&#34;,
    &#34;print-message&#34;: &#34;^2.1.0&#34;,
    &#34;react-native-easy-grid&#34;: &#34;0.1.7&#34;,
    &#34;react-native-keyboard-aware-scroll-view&#34;: &#34;0.2.7&#34;,
    &#34;react-native-scrollable-tab-view&#34;: &#34;^0.7.1&#34;,
    &#34;react-native-vector-icons&#34;: &#34;~4.0.0&#34;,
    &#34;react-tween-state&#34;: &#34;^0.1.5&#34;,
    &#34;tween-functions&#34;: &#34;^1.0.1&#34;,
    &#34;react-native-drawer&#34;: &#34;^2.3.0&#34;
},
</code></pre>

<p>干杯:) </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 运行 reactnative ios应用程序时找不到文件依赖错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/43817087/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/43817087/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 运行 react native ios应用程序时找不到文件依赖错误