I need help. I have this error when I run npm start:
/Users/telecreative/Documents/cafemates micro-services/cafemates-users-services/database/index.js:8
const pgp = require("pg-promise")(options) ^
On another computer, script running, with node version and npm version was same:
TypeError: require(...) is not a function
const express = require("express") const app = express() require('dotenv').config({path:__dirname+'/./../../.env'}) const promise = require("bluebird") const options = { promiseLib: promise } const pgp = require("pg-promise")(options) const config = { user: process.env.DATABASE_USER, host: process.env.DATABASE_HOST, database: process.env.DATABASE, password: process.env.DATABASE_PASSWORD, port: process.env.DATABASE_PORT } const db = pgp(config); module.exports = db
尝试从项目根目录运行npm install --save pg-promise bluebird
,然后重新加载该应用程序。
This: require("pg-promise")
simple does not return function.
Therefore when you use require("pg-promise")(...)
it tries to use it as function and then fails, because it is not a function.
You can try console.log(require("pg-promise")))
to see whats inside.
解决了我的问题,我从现有的json包中复制了json包。最好的方法应该是一一安装。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.