Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在react本机代码中导入pg_Node.js_Postgresql_Reactjs_React Native_Node Postgres - Fatal编程技术网

Node.js 在react本机代码中导入pg

Node.js 在react本机代码中导入pg,node.js,postgresql,reactjs,react-native,node-postgres,Node.js,Postgresql,Reactjs,React Native,Node Postgres,作为react native的新手,我正在尝试从我的react native应用程序连接postgreSQL。我已在我的react native应用程序上使用此npm install pg--save命令安装了pg模块。但是,如果我尝试在我的App.js(根组件或任何类组件)上导入pg,我会得到以下错误: 导入语法:(刚刚尝试了不同的语法) 从'pg'导入{Pool,Client} 从“pg”导入pg 从“pg”导入*为pg 错误: 错误:绑定失败:错误:无法从/node\u modules

作为
react native
的新手,我正在尝试从我的
react native
应用程序连接
postgreSQL
。我已在我的
react native
应用程序上使用此
npm install pg--save
命令安装了
pg
模块。但是,如果我尝试在我的
App.js
(根组件或任何类组件)上导入
pg
,我会得到以下错误:

导入语法:(刚刚尝试了不同的语法)

  • 从'pg'导入{Pool,Client}
  • 从“pg”导入pg
  • 从“pg”导入*为pg
错误:

错误:绑定失败:错误:无法从
/node\u modules/pg/lib/index.js中解析模块
util
:模块映射中不存在模块

注意:
const{Pool,Client}=require('pg')语法在
node+express
应用程序中运行良好

问题: 以下哪一个是非常好的解决方案?为什么?
  • 使用
    pg
    作为
    npm
    模块,导入
    react naive
    应用程序并连接到postgreSQL和access表

  • 如何在“ios”或“android”build\package上导入“pg”模块
  • “android/ios”是否有任何本机\节点库\模块可连接“react native”访问的“pg”
  • 使用node+expressAPI服务,并在
    fetch(类似axios的模块)
    的帮助下从react native应用程序连接该服务

  • 嗨,我也有同样的问题。你找到解决办法了吗?第二种方法工作正常,但需要第二台服务器来获取。