【发布时间】:2019-09-11 22:10:48
【问题描述】:
我无法访问我在 app.js 中导出的函数
在 app.js 文件中:
function getConnection() {
return mysql.createPool({
host: 'localhost',
user: 'root',
password: '',
database: 'Academind'
})
}
module.exports = {
getConnection: function () {
return getConnection()
}
}
在我的 orders.js 文件中:
const app = require('../../app')
function getConnection() {
return app.getConnection() // doesn't work
}
我收到此错误:
app.getConnection 不是函数
【问题讨论】:
标签: javascript node.js express npm node-modules