我用react-native init test创建了一个新的虚拟应用程序,然后按照说明添加了typeorm。在我的App.js中,我包括了import {getManager} from 'typeorm',然后运行了react-native run-ios。
我在地铁班德勒中看到了以下错误:
Error: Unable to resolve module path from /Users/amit/Code/test/node_modules/typeorm/platform/PlatformTools.js: Module path does not exist in the Haste module map下面是一个展示问题的示例存储库:在这里输入链接描述
不知道我是不是漏了什么东西!任何帮助都是受欢迎的!
发布于 2018-09-04 14:37:15
不幸的是,从“typeorm”模块导入无法工作,因为react本机项目没有非常灵活地使用节点平台。从“typeorm/browser”导入将有效。下面是一个示例项目.:https://github.com/typeorm/react-native-example
确保您创建的连接对象不使用对项目文件系统的任何引用。避免使用类似于:
import { CountSession } from '../biopro-mobile-database/entities/count_session';
const connection = await createConnection({
name: 'liteDb_3',
type: 'react-native',
database: 'biopro_mobile.sqlite',
location: 'default',
synchronize: false,
logging: true,
entities: ["../biopro-mobile-database/entities/**/*.ts"],
})避免使用["../biopro-mobile-database/entities//*.ts"],实体: **,而是使用以下内容:
import { EquipmentCounted } from '../biopro-mobile-database/entities/equipment_counted';
import { CountSession } from '../biopro-mobile-database/entities/count_session';
const connection = await createConnection({
name: 'liteDb_3',
type: 'react-native',
database: 'biopro_mobile.sqlite',
location: 'default',
synchronize: false,
logging: true,
entities: [
CountSession,
EquipmentCounted,
],
})https://stackoverflow.com/questions/50117535
复制相似问题