博览会无法解析模块

时间:2018-10-18 09:37:38

标签: react-native expo

赢得10个最新的博览会。用

设置一个新项目
npm install -g expo-cli
npm start

一切正常。然后将react-native-elements与以下代码一起添加到项目中:

import { Button } from 'react-native-elements';
<Button />;

显示Unable to resolve "react-native-elements" from "screens\LinksScreen.js"

这是app.json

{
  "expo": {
    "name": "Orange",
    "description": "A very interesting project.",
    "slug": "Orange",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "platforms": ["ios", "android"],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    }
  }
}

这是package.json

{
  "name": "my-new-project",
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/samples": "2.1.1",
    "expo": "^30.0.1",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
    "react-native-elements": "^0.19.1",
    "react-navigation": "^2.16.0"
  },
  "devDependencies": {
    "jest-expo": "30.0.0"
  }
}

有什么主意吗?

1 个答案:

答案 0 :(得分:0)

您是否已为react-native元素完成了npm安装?那很可能是你的问题。试试

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.showA = false;
    $scope.showB = false;
    $scope.showHide = function(val) {
      if(val === 'A'){
        this.showA = !this.showA;
      }
      else if(val === 'C'){
        this.showC = !this.showC;
      }
    };
});

在项目文件夹的命令行中。