首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应自然的TypeORM

反应自然的TypeORM
EN

Stack Overflow用户
提问于 2018-05-01 13:39:25
回答 1查看 2.6K关注 0票数 6

我用react-native init test创建了一个新的虚拟应用程序,然后按照说明添加了typeorm。在我的App.js中,我包括了import {getManager} from 'typeorm',然后运行了react-native run-ios

我在地铁班德勒中看到了以下错误:

代码语言:javascript
复制
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

下面是一个展示问题的示例存储库:在这里输入链接描述

不知道我是不是漏了什么东西!任何帮助都是受欢迎的!

EN

回答 1

Stack Overflow用户

发布于 2018-09-04 14:37:15

不幸的是,从“typeorm”模块导入无法工作,因为react本机项目没有非常灵活地使用节点平台。从“typeorm/browser”导入将有效。下面是一个示例项目.:https://github.com/typeorm/react-native-example

确保您创建的连接对象不使用对项目文件系统的任何引用。避免使用类似于:

代码语言:javascript
复制
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"],实体: **,而是使用以下内容:

代码语言:javascript
复制
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,
            ],
          })
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50117535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档