Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在React本机IOS中解析模块,但可在Android中工作_Javascript_Reactjs_React Native_React Native Ios_React Apollo - Fatal编程技术网

Javascript 无法在React本机IOS中解析模块,但可在Android中工作

Javascript 无法在React本机IOS中解析模块,但可在Android中工作,javascript,reactjs,react-native,react-native-ios,react-apollo,Javascript,Reactjs,React Native,React Native Ios,React Apollo,应用程序在X代码中成功构建,但在启动时出现此错误: Unable to resolve module `../node_modules/react-native/node_modules/react-apollo/react-apollo.browser.umd.js` from `/Users/lau/Documents/project/watch/mobile/src/Screen.js`: could not resolve `/Users/lau/Documents/projec

应用程序在X代码中成功构建,但在启动时出现此错误:

Unable to resolve module 
`../node_modules/react-native/node_modules/react-apollo/react-apollo.browser.umd.js` 
from `/Users/lau/Documents/project/watch/mobile/src/Screen.js`: 
could not resolve 
`/Users/lau/Documents/project/watch/mobile/node_modules/react-native/node_modules/react-apollo/react-apollo.browser.umd.js' 
as a file nor as a folder
我认为问题是由于路径中有额外的
/node\u模块/react native/

。/node\u modules/react apollo/react apollo.browser.umd.js中有文件,但
。/node\u modules/react native/node\u modules/react apollo/react apollo.browser.umd.js中没有文件。我不明白为什么在react-native IOS中路径的前缀是不必要的
/node\u modules/react-native/
。它是由生成设置中的搜索路径引起的吗

以下是我如何在Screen.js中导入react apollo模块:

import * as React from 'react'
import {Navigation} from 'react-native-navigation';
import {ApolloProvider} from "react-apollo";
生成设置:

package.json:

  "dependencies": {
    "apollo-cache-inmemory": "^1.2.7",
    "apollo-cache-persist": "^0.1.1",
    "apollo-client": "^2.3.8",
    "apollo-client-preset": "^1.0.8",
    "apollo-engine": "^1.1.2",
    "apollo-link": "^1.2.2",
    "apollo-link-batch-http": "^1.2.2",
    "apollo-link-context": "^1.0.8",
    "apollo-link-persisted-queries": "^0.2.1",
    "apollo-link-state": "^0.4.1",
    "react": "^16.4.2",
    "react-apollo": "^2.1.11",
    "react-native": "0.56.0",
    "react-native-navigation": "^2.0.2471"
  },

我刚刚删除了./nomble_模块,运行
npm安装
,并从
中删除这个块

  "plugins": [
    ["module-resolver", {
      "alias": {
        "react-apollo": "react-apollo/react-apollo.browser.umd.js"
      }
    }]
  ]
事情进展顺利。 也许在一些阿波罗模块的版本中存在冲突