繁体   English   中英

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

[英]File not found dependency error while running react native ios app

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

尝试通过执行以下操作将其删除:

npm uninstall --save react-native-router-flux

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

这是我的终端中显示的内容:

error: bundling: Error: ENOENT: no such file or directory, open '/Users/marian-mac/Documents/dev/example/myapp/node_modules/react-native-router-flux/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js'
    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)

我尝试 rm -rf /node_modules 100 次,然后 npm 安装另外 100 次,这一直失败和失败,我不明白在哪里尝试访问该文件! 如果删了!!!

这是我的 package.json 现在:

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

也对版本和其他事情抛出警告:

npm WARN native-base-shoutem-theme@0.1.3 requires a peer of react@>=15.1.0 but none was installed.
npm WARN @shoutem/animation@0.8.10 requires a peer of react@^15.0.0 but none was installed.
npm WARN react-static-container@1.0.1 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.

这是针对本机基础依赖项抛出的:

 UNMET PEER DEPENDENCY react@^0.13.0 || ^0.14.0 || ^15.0.0

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

提前致谢。


编辑:

在为 react、react-native 和 native-base 更改了一些版本之后。 仍然有警告,看起来打包者正在尝试访问 react-native-route-flux 中的 react-native 文件。

1) 这是我目前的 package.json

├─┬ native-base@2.1.3
│ ├─┬ @shoutem/animation@0.8.10
│ │ ├── hoist-non-react-statics@1.2.0
│ │ └── lodash@4.17.4
│ ├── blueimp-md5@2.7.0
│ ├── clamp@1.0.1
│ ├─┬ color@0.11.4
│ │ ├── clone@1.0.2
│ │ ├─┬ color-convert@1.9.0
│ │ │ └── color-name@1.1.2
│ │ └── color-string@0.3.0
│ ├─┬ fs-extra@2.1.2
│ │ └── jsonfile@2.4.0
│ ├── lodash@4.11.2
│ ├── native-base-shoutem-theme@0.1.3
│ ├── print-message@2.1.0
│ ├── UNMET PEER DEPENDENCY react@^15.0.0
│ ├── react-native-drawer@2.3.0
│ ├── react-native-easy-grid@0.1.7
│ ├── react-native-keyboard-aware-scroll-view@0.2.7
│ ├─┬ react-native-scrollable-tab-view@0.7.4
│ │ ├── UNMET PEER DEPENDENCY react@^0.13.0 || ^0.14.0 || ^15.0.0
│ │ └── react-static-container@1.0.1
│ ├── react-native-vector-icons@4.0.1
│ ├─┬ react-tween-state@0.1.5
│ │ └─┬ raf@3.3.2
│ │   └── performance-now@2.1.0
│ └── tween-functions@1.2.0
├─┬ UNMET PEER DEPENDENCY react@16.0.0-alpha.3

2)这些是警告:

 npm WARN react-native@0.43.4 requires a peer of react@16.0.0-alpha.6 but none was installed. npm WARN native-base-shoutem-theme@0.1.3 requires a peer of react@>=15.1.0 but none was installed. npm WARN @shoutem/animation@0.8.10 requires a peer of react@^15.0.0 but none was installed. npm WARN react-static-container@1.0.1 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed. npm WARN react-test-renderer@16.0.0-alpha.6 requires a peer of react@^16.0.0-alpha.6 but none was installed.

还在原生基础上抛出一些未满足的对等依赖:

 ├─┬ native-base@2.1.3 │ ├─┬ @shoutem/animation@0.8.10 │ │ ├── hoist-non-react-statics@1.2.0 │ │ └── lodash@4.17.4 │ ├── blueimp-md5@2.7.0 │ ├── clamp@1.0.1 │ ├─┬ color@0.11.4 │ │ ├── clone@1.0.2 │ │ ├─┬ color-convert@1.9.0 │ │ │ └── color-name@1.1.2 │ │ └── color-string@0.3.0 │ ├─┬ fs-extra@2.1.2 │ │ └── jsonfile@2.4.0 │ ├── lodash@4.11.2 │ ├── native-base-shoutem-theme@0.1.3 │ ├── print-message@2.1.0 │ ├── UNMET PEER DEPENDENCY react@^15.0.0 │ ├── react-native-drawer@2.3.0 │ ├── react-native-easy-grid@0.1.7 │ ├── react-native-keyboard-aware-scroll-view@0.2.7 │ ├─┬ react-native-scrollable-tab-view@0.7.4 │ │ ├── UNMET PEER DEPENDENCY react@^0.13.0 || ^0.14.0 || ^15.0.0 │ │ └── react-static-container@1.0.1 │ ├── react-native-vector-icons@4.0.1 │ ├─┬ react-tween-state@0.1.5 │ │ └─┬ raf@3.3.2 │ │ └── performance-now@2.1.0 │ └── tween-functions@1.2.0 ├─┬ UNMET PEER DEPENDENCY react@16.0.0-alpha.3

在控制台中运行时,在模拟器中从 XCode 抛出红屏错误说:

No Dimension set for key window

根据他的github,看起来这是一个已知问题 但是该死的,我不再想要 react-native-router-flux,我什至没有在我的 package.json 中也没有安装它并且仍然造成麻烦,这种依赖是一种病毒。

每当您遇到这种情况时,请冷静并思考安装核心第三方时所有其他第三方都安装了什么。 我在玩react-native-router-flux时遇到了类似的问题,它的稳定版本是v3.38.0

从上面的问题来看, @shoutem/animation@0.8.10react-static-container@1.0.1似乎带有react-native-router-flux库。 另一个包即native-basereact@>=15.1.0

所以我得出结论,从节点模块中删除@shoutemreact-static-container 如果仍然存在错误,那么我该死的确定错误是由于本机基础引起的。 从项目中完全删除native base并等待native base更新到最新版本的react

尝试以上操作,请分享进度,因为这也可以帮助其他人。

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

使用npm install package-name@xy更新包,其中 xy 是您要安装的版本号。

注2:安装包yarn是首选。

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

"dependencies": {
    "lodash.isequal": "^4.5.0",
    "react": "^15.4.2",
    "react-addons-pure-render-mixin": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-native": "^0.41.2",
    "react-native-experimental-navigation": "0.26.x",
    "react-native-tabs": "^1.0.9",
    "react-static-container": "1.0.1"
  },

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

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

干杯:)

npm install react-native-reanimated 
react-native-gesture-handler 
react-native-screens 
react-native-safe-area-context 
@react-native-community/masked-view

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM