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. LeetCode(155)题解--Min Stack

    https://leetcode.com/problems/min-stack/ 题目: Design a stack that supports push, pop, top, and retrie ...

  2. cerery

    cerery http://docs.celeryproject.org/en/latest/userguide/index.html

  3. 初识代码封装工具SWIG(回调Python函数)

    这不是我最早使用swig了,之前在写Kynetix的时候就使用了swig为python封装了C语言写的扩展模块.但是当时我对C++还不是很了解,对其中的一些概念也只是拿来直接用,没有理解到底是什么,为 ...

  4. JavaWeb浏览器传值乱码

    在Java服务接口调用中,可能会出现乱码,如下图所示: 这是由编码不一致而致的乱码,可转,如下: name = new String(name.getBytes("ISO-8859-1&qu ...

  5. jvm调试

    https://www.usenix.org/legacy/events/jvm01/full_papers/russell/russell_html/index.html

  6. include vector 编译出错VC++

    error C2665: “operator new” : 5个重载中没有一个可以转换参数1(从“const char [71]”类型)这个错误是怎么回事啊,搜索了整个项目好像没有可疑的new操作阿. ...

  7. user版本如何永久性开启adb 的root权限【转】

    本文转载自:http://blog.csdn.net/o0daxu0o/article/details/52933926 [Solution]* adb 的root 权限是在system/core/a ...

  8. Appium java 环境配置

    一.安装node.js 下载地址:http://pan.baidu.com/s/1qYyNDm8 点击安装,next下一步就ok. 安装完成,命令行输入:npm 这样显示的话就ok了.  二.下载Ap ...

  9. MYSQL进阶学习笔记十六:MySQL 监控!(视频序号:进阶_35)

    知识点十七:MySQL监控(35) 一.为什么使用MySQL监控 随着软件后期的不断升级,myssql的服务器数量越来越多,软硬件故障的发生概率也越来越高.这个时候就需要一套监控系统,当主机发生异常时 ...

  10. bzoj2132【圈地计划】

    题面 思路: 一开始以为和为了博多一样,两边连一样的,后来发现中间连负边的话根本不会割,即割断两块收益为负,所以WA的起飞…… 正解是先黑白染色,每个点和它周围的点连边方式不同.对于黑点A,S--&g ...