无法安装目录中存在的屏幕模块

时间:2018-06-09 10:12:38

标签: react-native expo

当我尝试通过snack.expo在模拟器或设备上运行app时,我收到此错误:

  

设备:(741:6637)无法安装模块'project_modules / containers /<%name%>':无法下载模块'project_modules~container~<%name%> @latest'    从app.js导入

<%名称%GT;可以在不同的屏幕之间进行更改,所有这些都来自目录project_modules / containers / 代码:

  

App.js

import React from 'react';

import { createStackNavigator } from 'react-navigation';
import AuthScreen from 'project_modules/containers/auth_screen'
import SelectProjectScreen from     'project_modules/containers/select_project_screen'
import ProjectScreen from 'project_modules/containers/project_screen'
import SelectTaskScreen from 'project_modules/containers/project_select_task_screen'
import TeamScreen from 'project_modules/containers/project_team_screen'
import CamerasScreen from 'project_modules/containers/project_cameras_screen'
import store from "./project_modules/instances/store";
import {Provider} from "react-redux";
import {INITIAL_PARAMS} from "./project_modules/constants/state_constants/project_constants";

const Root = createStackNavigator({
    SelectProject: {screen: SelectProjectScreen},
    ProjectScreen: {screen: ProjectScreen},
    SelectTaskScreen: {screen: SelectTaskScreen},
    TeamScreen: {screen: TeamScreen},
    CamerasScreen: {screen: CamerasScreen},
    AuthScreen: {screen: AuthScreen}
}, {
    initialRouteName: 'AuthScreen',
    initialRouteParams: INITIAL_PARAMS
});

const App = () => {
    return (
        <Provider store={store}>
            <Root/>
        </Provider>
    )
};

export default App
  

index.js

import {AppRegistry} from 'react-native';
import App from './App';

AppRegistry.registerComponent('SIBM', () => App);
  

的package.json

{
    "name": "SIBM",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "babel-loader": "^7.1.4",
        "core-decorators": "^0.20.0",
        "expo": "^27.0.1",
        "firebase": "^5.0.3",
        "react": "16.3.1",
        "react-native": "0.55.4",
        "react-native-dropdownalert": "^3.4.0",
        "react-native-fontawesome": "^5.7.0",
        "react-native-swipeable": "^0.6.0",
        "react-native-vector-icons": "^4.6.0",
        "react-navigation": "^2.0.1",
        "react-redux": "^5.0.7",
        "redux": "^4.0.0"
    },
    "devDependencies": {
        "babel-cli": "^6.26.0",
        "babel-jest": "22.4.3",
        "babel-plugin-transform-es2015-modules-amd": "^6.24.1",
        "babel-preset-env": "^1.6.1",
        "babel-preset-react": "^6.24.1",
        "babel-preset-stage-0": "^6.24.1",
        "babel-preset-react-native": "4.0.0",
        "babel-preset-es2015": "^6.24.1",
        "babel-env": "^2.4.1",
        "jest": "22.4.3",
        "react-test-renderer": "16.3.1",
        "eslint": "^4.19.1",
        "eslint-plugin-react": "^7.7.0",
        "webpack": "^4.8.1"
    },
    "jest": {
        "preset": "react-native",
        "transform": {
            "^.+\\.js?$": "babel-jest"
        },
        "transformIgnorePatterns": [
            "node_modules/(?!(jest-)?react|react-native|react-navigation)"
        ],
        "testPathIgnorePatterns": [
            "/node_modules/"
        ]    
    }
}

1 个答案:

答案 0 :(得分:0)

此问题通过绝对路径打包解决。 我在每个大目录中都添加了自己的带有字段“名称”的 package.json 。然后我得到这样的进口:

import AuthScreen from 'containers/auth_screen'