反应本机run-ios或run-android错误

时间:2016-07-26 02:21:38

标签: reactjs npm react-native

我试图使用这个项目

https://github.com/FaridSafi/react-native-gifted-listview

我会写下订单处理。

  1. 下载project.zip&解压

  2. 在终端中,我使用了这个命令[npm install]

  3. 这个[react-native run-android]& [react-native run-ios]

  4. 但我未能建立这个项目。

    open-ui-iMac:react-native-gifted-listview-master openobject $ react-native run-android 找不到Android项目。也许首先运行react-native android?

    open-ui-iMac:react-native-gifted-listview-master openobject $ react-native run-ios /Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/done.js:10       扔错了;       ^

    错误:ENOENT:没有这样的文件或目录,uv_chdir

    at Error (native)
    at process.chdir (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/graceful-fs/polyfills.js:18:9)
    at _runIOS (node_modules/react-native/local-cli/runIOS/runIOS.js:50:11)
    at node_modules/react-native/local-cli/runIOS/runIOS.js:24:5
    at tryCallTwo (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:45:5)
    at doResolve (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:200:13)
    at new Promise (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:66:3)
    at Array.runIOS (node_modules/react-native/local-cli/runIOS/runIOS.js:23:10)
    at Object.run (node_modules/react-native/local-cli/cliEntry.js:95:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:88:7)
    

    我找到了一些解决方案。

    他们说&#34;使用此命令&#34;

    rm -rf node_modules

    rm -fr $ TMPDIR / react - *

    守望者手表 - 所有

    npm install --save react-native @ latest

    但它无法解决这个问题

    我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:1)

您正在尝试在项目中使用第三方React Native Component。安装和使用Component的正确方法如下:

  1. 进入react-native项目:cd yourProject
  2. 终端上运行以下代码:npm install react-native-gifted-listview --save。这是安装组件的方法。 npm install component-name --save

  3. 在您要使用的页面中导入已安装的组件:import GiftedListView from 'react-native-gifted-listview';

  4. 现在您可以使用组件:

  5. <GiftedListView
      rowView={this._renderRowView}
      onFetch={this._onFetch}
      firstLoader={true} 
      pagination={true} 
      refreshable={true} 
      withSections={false}
      refreshableTintColor="blue"
    />