Node中使用MySQL报错:TypeError: Cannot read property 'query' of undefined
Node中使用MySQL报错:
TypeError: Cannot read property 'query' of undefined
at /Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/models/user.js::
at Handshake.onConnect [as _callback] (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/Pool.js::)
at Handshake.Sequence.end (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/protocol/sequences/Sequence.js::)
at Handshake.ErrorPacket (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/protocol/sequences/Handshake.js::)
at Protocol._parsePacket (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/protocol/Protocol.js::)
at Parser.write (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/protocol/Parser.js::)
at Protocol.write (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/protocol/Protocol.js::)
at Socket.<anonymous> (/Users/sipeng/Desktop/彭思/2017年学习/Node/sampleEjs/sampleEjs/node_modules/mysql/lib/Connection.js::)
at emitOne (events.js::)
at Socket.emit (events.js::)
解决办法:
如下图所示将host改为localhost即可.

使用Express-session出现以下问题:
express-session deprecated undefined resave option; provide resave option app.js::
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option app.js::
解决办法:
app.js,session 加两个参数:
app.use(session({
resave: true, // 新增
saveUninitialized: true, // 新增
secret: config.secret,
}));
Node中使用MySQL报错:TypeError: Cannot read property 'query' of undefined的更多相关文章
- VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法
正常情况下在data里面都有做了定义 在函数里面进行赋值 这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of ...
- vue表单校验提交报错TypeError: Cannot read property 'validate' of undefined
TypeError: Cannot read property 'validate' of undefined at VueComponent.submitForm (plat_users.html: ...
- 使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法
我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are rec ...
- vue报错TypeError: Cannot read property 'protocol' of undefined
错误信息如下所示: isURLSameOrigin.js?3934:57 Uncaught (in promise) TypeError: Cannot read property 'protocol ...
- react报错 TypeError: Cannot read property 'setState' of undefined
代码如下: class test extends Component { constructor(props) { super(props); this.state = { liked: false ...
- vue报错TypeError: Cannot read property '$createElement' of undefined
报错截图: 这个错误就是路由上的component写成了components
- Node.js报错TypeError: Cannot read property 'isDirectory' of undefined
截图如下: 原因如下:记住"./uploads" 后要加一个/ fs.stat("./uploads/" + files[i], function(err, s ...
- VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法
created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then( ...
- JS报错:Cannot read property 'type' of undefined
在做图片上传功能的时候,遇到了JS无法识别图片type的问题,在使用过程中是没有问题的,但是不知道为什么浏览器的Console报这个错误: Uncaught TypeError: Cannot rea ...
随机推荐
- Android adb的一些用法
adb查看包名/Activity名 adb shell "logcat | grep START" adb shell dumpsys activity | find “mFocu ...
- 2019-2020-1 20199312《Linux内核原理与分析》第四周作业
计算机和操作系统的法宝 计算机三个法宝 存储程序计算机.函数调用堆栈机制.中断 操作系统:中断中断上下文的切换--保护和恢复现场 进程上下文的切换. Linux源代码目录分析 arch目录:代码量庞大 ...
- Codeforces Round #533 (Div. 2) D. Kilani and the Game(BFS)
题目链接:https://codeforces.com/contest/1105/problem/D 题意:p 个人在 n * m 的地图上扩展自己的城堡范围,每次最多走 a_i 步(曼哈顿距离),按 ...
- 洛谷P2051 中国象棋【dp】
题目:https://www.luogu.org/problemnew/show/P2051 题意:n*m的格子里放炮,使他们不能互相攻击. 如果两个炮在同一行同一列并且中间还有一个棋子的话就可以攻击 ...
- js 定义数组转json
var msgData = {} msgData["url"] = openUrl msgData["courseName"] = val.name JSON. ...
- 使用python画一颗圣诞树
# -*- coding: utf-8 -*- # @Time : 18-12-26 上午9:32 # @Author : Felix Wang import turtle # 定义圣诞树的绿叶函数 ...
- MySQL 聚集拼接
GROUP_CONCAT()函数 示例: 假设现在有这样一个表结构: 其中`student`.`school_id`是逻辑外键 想要检索出所有学校,其中学校下的学生名需要拼接在一起,作为结果集的字段 ...
- python 的单例
例子 class Singleton(object): _instance = None def __new__(cls, *args, **kw): if not cls._instance: cl ...
- ZR#988
ZR#988 解法: 先算出横着能排多少座位, 以及需要排几列, 才能把 n 个座位全部排下来.要使得尽量多的位置在走廊边上, 于是在 n 列中插入走廊的策略是显然的, 我们只要以两列为单位, 在其中 ...
- vue中的父组件传值给子组件
以上父组件以及父组件里面的代码 下面是子组件以及里面的代码