Ami*_*mit 5 sqlite react-native typeorm
我使用创建了一个新的虚拟应用程序react-native init test,然后按照说明添加typeorm。在我的App.js中,包括import {getManager} from 'typeorm',然后运行react-native run-ios。
我在Metro-Bundler中看到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
这是显示问题的示例存储库:在此处输入链接描述
不知道我是否错过了设置!任何帮助都非常欢迎!
小智 5
不幸的是,从“typeorm”模块导入不起作用,因为反应本机项目不完全使用节点平台。从“typeorm/浏览器”导入将起作用。这是一个示例项目: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"],
})
Run Code Online (Sandbox Code Playgroud)
避免实体: ["../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,
],
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
941 次 |
| 最近记录: |