【问题标题】:Seeing error Module not found: 'pg-native' in heroku app看到错误模块未找到:heroku 应用程序中的 'pg-native'
【发布时间】:2017-05-22 13:02:06
【问题描述】:

我正在尝试将 postgres 插件与同样使用 react 的 heroku 节点应用程序一起使用。

我正在使用这个 react buildpack 来支持 heroku 中的 react: https://github.com/opike/create-react-app-buildpack.git

当我尝试添加该行时:

var pg = require('pg');

当我尝试在本地运行 heroku 应用程序时出现以下编译错误:

>heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
[WARN] ENOENT: no such file or directory, open 'Procfile'
[OKAY] package.json file found - trying 'npm start'
4:15:19 PM web.1 |  > test-app@0.1.0 start /Users/oliverpike/dev/heroku/ofp-react
4:15:19 PM web.1 |  > react-scripts start
4:15:20 PM web.1 |  Starting the development server...
4:15:29 PM web.1 |  Failed to compile.
4:15:29 PM web.1 |  Error in ./~/pg/lib/native/index.js
4:15:29 PM web.1 |  Module not found: 'pg-native' in /Users/oliverpike/dev/heroku/ofp-react/node_modules/pg/lib/native
4:15:29 PM web.1 |   @ ./~/pg/lib/native/index.js 1:13-33
4:15:29 PM web.1 |  Error in ./~/pg/lib/connection-parameters.js
4:15:29 PM web.1 |  Module not found: 'dns' in /Users/oliverpike/dev/heroku/ofp-react/node_modules/pg/lib
4:15:29 PM web.1 |   @ ./~/pg/lib/connection-parameters.js 2:10-24

【问题讨论】:

    标签: node.js reactjs heroku heroku-postgres


    【解决方案1】:

    我能够通过以下方式解决这个问题:

    > npm i pg-native
    

    如此处所述: https://github.com/brianc/node-pg-native

    还有一个

    > npm i dns
    

    关于 dns 问题。

    奇怪的是,我不需要在其他使用 postgres 的 heroku 应用中显式安装这些包。

    【讨论】:

      猜你喜欢
      • 2021-06-17
      • 2019-04-26
      • 1970-01-01
      • 2016-09-10
      • 2022-07-28
      • 1970-01-01
      • 1970-01-01
      • 2020-04-27
      • 2019-01-21
      相关资源
      最近更新 更多