{ // res.render('login'); var data = knex.-6ren">
gpt4 book ai didi

mysql - 当我运行 app.js 时,它显示错误 "TypeError: knex.select is not a function"

转载 作者:行者123 更新时间:2023-11-29 16:14:51 25 4
gpt4 key购买 nike

我在 app.js 文件中有这段代码,

   app.get('/', (req, res) => {
// res.render('login');
var data = knex.select('*').from('RegisterData');
res.send(data)
console.log(data);
});

最佳答案

在评论中(您确实应该更新您的问题以反射(reflect)这些),您说您定义了 knex :

const knex = require('knex');

您应该查看 Node.js installation section 中的初始化库段落。 .

它应该看起来像:

const knex = require('knex')({
client: 'mysql',
connection: {...}
});

这意味着 knex 应该是 require 公开的调用函数的结果

关于mysql - 当我运行 app.js 时,它显示错误 "TypeError: knex.select is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54920391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com