D:\le\node_modules\mysql\lib\protocol\Parser.js:
throw err; // Rethrow non-MySQL errors
^ Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the cli
ent
at ServerResponse.setHeader (_http_outgoing.js::)
at ServerResponse.header (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.send (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.json (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.send (D:\le\node_modules\express\lib\response.js::
)
at D:\le\routes\cart.js::
at D:\le\models\cart.js::
at Query._callback (D:\le\models\db.js::)
at Query.Sequence.end (D:\le\node_modules\mysql\lib\protocol\sequences\Se
quence.js::)
at Query.ErrorPacket (D:\le\node_modules\mysql\lib\protocol\sequences\Que
ry.js::)
npm ERR! code ELIFECYCLE
npm ERR! errno
npm ERR! letao@0.0. start: `node ./bin/www`
npm ERR! Exit status
npm ERR!
npm ERR! Failed at the letao@0.0. start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above. npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\administrator\AppData\Roaming\npm-cache\_logs\--28T11_00_46_4
81Z-debug.log D:\letao>

注意其中at Query._callback (D:\le\models\db.js:44:22)找到models\db.js44行

    pool.getConnection(function(err, connection) {
if (err) {
// callback(err);
return callback(err);
}
connection.query(sqlStr, params, function(err, rows) {
if (err) {
// callback(err);
return callback(err);
}
connection.release();
callback.apply(null, arguments);//报错行44
});
});

在callback(err)前加return上述错误解决了。具体原因详见参考文章。

参考文章:

https://stackoverflow.com/questions/7042340/error-cant-set-headers-after-they-are-sent-to-the-client
https://cnodejs.org/topic/53774ffecbcc396349ca1155
https://cnodejs.org/topic/5635fed78c67728402553324
https://stackoverflow.com/questions/27658997/cant-set-headers-after-they-are-sent-on-express

Cannot set headers after they are sent to the client的更多相关文章

  1. Nodejs实现简单的反向代理

    var http = require('http'), httpProxy = require('http-proxy'); // 新建一个代理 Proxy Server 对象 var proxy = ...

  2. c# WebClient文件下载

    public void HttpDownload(string url, string path, ResourceType type) { using (var client = new WebCl ...

  3. webclient的简单实用

    这是我在项目中调用别人写好的接口口是使用的1.简单的url传参 List<ArticleModel> result = new List<ArticleModel>(); st ...

  4. 通过rpc访问比特币核心钱包

    开发环境和工具 1. window 10 64 2. 比特核心钱包:bitcoin core 64 配置过程 1. 下载比特币核心钱包,下载链接https://bitcoin.org/en/downl ...

  5. 用任意语言与WebService进行交互

    using System; using System.Web.Services; using YY.SmsPlatform.Common.Objects; using YY.SmsPlatform.C ...

  6. .net WebClient发送请求实例:

    public static Main(string [] ager) { WebClient client = new WebClient(); client.Headers.Clear(); cli ...

  7. webapi 中使用 protobuf

    相比json来说,好处是速度更快,带宽占用更小.其效果大致等于json+Gzip. 在webapi中使用protobuf的方法为: 引用nuget包 Install-Package protobuf- ...

  8. Getting Started with ASP.NET Web API 2 (C#)

    By Mike Wasson|last updated May 28, 2015 7556 of 8454 people found this helpful Print   Download Com ...

  9. WebClient 使用

    --post  请求 public static string PostMsg(Guid orgid, int page, int rows)        {            System.N ...

随机推荐

  1. 安卓版本6.0打开uiautomator报错

    可能是appium打开了,被占用:或者是找不到手机

  2. linux下启动和关闭weblogic(转载)

    在weblogic定义的域中可以找到如下命令: /[youHome]/domains/[yourDomain]/startWebLogic.sh /[youHome]/domains/[yourDom ...

  3. OpenCV 入门示例之一:显示图像

    前言 本文展示一个显示图像的示例程序,它用于从硬盘加载一副图像并在屏幕上显示. 代码示例 // 此头文件包含图像IO函数的声明 #include "highgui.h" int m ...

  4. 第 1 章 第 1 题 高级语言的排序问题 C++标准算法实现

    问题分析 依题意,所需程序不用过多考虑效率且暗示使用库,自然想到用高级语言实现(个人选择C++).可用顺序容器暂存数据,用标准算法解决排序问题. 代码实现 #include <iostream& ...

  5. Hibernate的基本开发流程

    一.Hibernate开发的基本流程 二.Hibernate开发的环境搭建 1.引入Hibernate核心包以及Hibernate依赖包即可.可以在Hibernate目录下的\lib\required ...

  6. LVS集群中的IP负载均衡技术

    LVS集群中的IP负载均衡技术 章文嵩 (wensong@linux-vs.org) 转自LVS官方参考资料 2002 年 4 月 本文在分析服务器集群实现虚拟网络服务的相关技术上,详细描述了LVS集 ...

  7. Gym - 100676E —— 基础题

    题目链接:https://odzkskevi.qnssl.com/1110bec98ca57b5ce6aec79b210d2849?v=1490453767 题解: 这种方法大概跟离散化扯上点关系:首 ...

  8. zkui部署

    1.拉取代码 #git clone https://github.com/DeemOpen/zkui.git 2.构建并安装程序 #cd zkui/ #yum install -y maven #mv ...

  9. U盘安装Ubuntu 14.04 LTS正式版

    Ubuntu 14.04 LTS正式版发布,而且提供五年的支持和维护服务.Ubuntu 14.04是Ubuntu开发团队历经五年的心血之作.许多新手都喜欢把Linux安装文件刻录成光盘再安装,而安装好 ...

  10. Android记录程序崩溃Log写入文件

    将导致程序崩溃的堆栈调用Log写入文件,便于收集bug.在调试安卓程序,由于某些原因调试时手机不能连接PC端,无法通过IDE查看程序崩溃的Log,希望log能够写入文件中,对于已经发布的App可以通过 ...