我一直在尝试在我的android手机上运行expo上的本地应用程序react。我一直无法解决,因为在expo上无法解决"components/MenuComponent.js“中的"../shared/baseUrl”错误。
这是我的项目的文件夹树,在这里您可以看到baseUrl和MenuComponent.js (组件上的其他js模块导入了错误的baseUrl.js ):

以下是组件/MenuComponent.js的imports部分:
import React, { Component } from 'react';
import { View, FlatList } from 'react-native';
import { Tile } from 'react-native-elements';
import { connect } from 'react-redux';
import { baseUrl } from '../shared/baseUrl';
以下是共享/shared Urls.js的内容
export const baseUrl = 'http://localhost:3001/';
这是我的package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject"
},
"dependencies": {
"expo": "^32.0.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-elements": "^1.0.0-beta8",
"react-navigation": "2.0.1",
"react-redux": "5.0.7",
"redux": "4.0.0",
"redux-logger": "3.0.6",
"redux-thunk": "2.2.0"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0"
},
"private": true
}
我使用这些软件包的版本,因为它们是建议在我的课程。
为了解决这个问题,我已经试过了
发布于 2019-03-28 13:26:45
以下是共享/shared Urls.js的内容
你确定这些路是正确的吗?如果您临时将文件移动到同一个文件夹中并将其包含在其中,会发生什么?import { baseUrl } from './baseUrl';
https://stackoverflow.com/questions/55366110
复制相似问题