![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
nodejs
newborn2012
学IT如做豆腐关键阶段得有人点化
展开
-
nodejs中使用jquery出现“jQuery requires a window with a document”错误的解决方案
jquery也是可以在服务端使用的,使用npm安装jquery模块即可:$npm install -g jquery但是实际使用时发现报了这么一个错误:jQuery requires a window with a document。原因是默认安装jquery时,版本是最新版2.1.0,这个版本没有包括jsdom,需要额外安装一个jsdom,然后这么使用:var jsdom = r原创 2014-02-25 23:29:48 · 9744 阅读 · 2 评论 -
nodejs request模块gzip response的解压问题
参看:https://github.com/mikeal/request/issues/747这个解决方法太蛋疼了,原来需要在转载 2014-04-29 12:47:33 · 7646 阅读 · 0 评论 -
npm添加国内镜像
npm config set registry http://registry.cnpmjs.org原创 2014-03-25 15:45:06 · 1400 阅读 · 0 评论 -
欲善其功,必先利其器--Nodejs调试技术总结
转自:http://www.cnblogs.com/moonz-wu/archive/2012/01/15/2322120.html转载 2014-04-22 10:27:36 · 1204 阅读 · 0 评论 -
nodejs处理图片文件上传
参考资料:1,Upload progress bar working with apache, nginx and lighttpd upload progress modules2,模拟AJAX无刷新的文件上传功能3,关于真正的Ajax方式上传文件原创 2013-11-19 15:26:29 · 20343 阅读 · 9 评论 -
express建立https服务器
首先需要创建证书文件:$openssl genrsa -out privatekey.pem 1024$openssl req -new -key privatekey.pem -out certrequest.csr$openssl x09 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem原创 2013-12-19 23:01:01 · 3190 阅读 · 0 评论 -
win7 64位下安装nodejs 的jquery@1.6.3时无法安装依赖包jsdom的解决办法
jsdom又依赖于contextify,而contextify又需要gyp来重新编译,安装过程中老是报错,如下:gyp ERR! configure errorgyp ERR! stack Error: spawn ENOENTgyp ERR! stack at errnoException (child_process.js:980:11)gyp ERR! stack原创 2014-03-07 10:49:46 · 2608 阅读 · 0 评论 -
在aliyun的centos系统中编译node时出现错误:No Module Named bz2
由于aliyun的centos中的python版本默认为2.6.6,有些程序要求使用更高版本的python,所以就先升级了python,但是编译node时却出现了错误:No Moduel named bz2。解决方法:1,安装bzip*#yun install -y bzip*2,再次重新安装python2.7.33,最后重新编译node。原创 2014-03-25 15:42:46 · 1830 阅读 · 0 评论 -
使用端口转发解决nodejs在80端口上的监听权限问题
由于linux的系统限制,普通用户是无法打开1024yi原创 2014-04-16 17:24:09 · 13521 阅读 · 0 评论 -
Express设置主机头
摘自 https://github.com/visionmedia/express/blob/master/examples/vhost/index.js /** * Module dependencies. */ var express = require('../..'); /* edit /etc/hosts: 127.0.0.1 foo.example.com 127.0.0.1 bar.转载 2013-11-18 20:25:36 · 3391 阅读 · 0 评论 -
在win7 64上用npm安装phantomjs时出现Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE错误的解决方法。
解决方案在stackoverflow上找到的,关掉strict-ssl即可,如下:npm config set strict-ssl false用完之后恢复:npm config set strict-ssl true原创 2014-03-12 08:56:12 · 6921 阅读 · 0 评论 -
express接收base64编码数据和文件存储
转自:http://marshal.easymorse.com/archives/4935图片在浏览器的javascript中操作,只能是base64编码的文本。比如从html5 canvas存储图片,只能生成base64编码的文本,通过toDataURL()方法。生成的输入类似这样:data:image/png;base64,iVBORw0KGgoAAAA转载 2014-01-02 10:40:45 · 4298 阅读 · 0 评论 -
cron用来在linux调度任务,cron的时间格式
转自:http://blog.csdn.net/abner0914/article/details/5907978一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素。 按顺序依次为:秒 (0~59)分钟 (0~59)小时 (0~23)天(月) (0~31,但是你需要考虑你月的天数)月转载 2014-01-02 12:59:01 · 1539 阅读 · 0 评论 -
用nodejs监控网站是否挂掉了,如果挂掉就发一封邮件到指定地址。
你不可能随时盯着网站,每隔一段时间刷新一次,看看网站是否还正常运行,所以最好能有一个程序自动帮你做监控,当网站无法正常访问时,立即通知你。这里需要解决的是这几个问题:1,怎么判断网站是否挂了?2,怎么自动发送邮件到指定地址?3,nodejs中怎么调用外部命令发送邮件?1,怎么判断网站是否挂了?可以使用http.get的方式获取指定的网页,如果出错,则表示网站出问题了。原创 2014-02-12 14:14:38 · 4722 阅读 · 0 评论 -
nodejs中的cron
在linux下使用crontab来进行任务调度十分方便,你可以指定每隔一段时间执行指定的程序、也可以指定每天的某个时刻执行某个程序、还可以按照星期、月份来指定。在nodejs中也有类似的cron模块,可以实现同样的功能,时间语法也一样。1,安装cron模块#npm install -g cron2,启动一个任务var cronJob = require("cron").CronJo原创 2014-02-12 15:58:45 · 13335 阅读 · 0 评论 -
npm安装nodejs模块时,有些模块因为墙的原因无法安装,可以使用指定代理来解决。
npm安装nodejs模块时,有些模块因为墙的原因无法安装,可以使用指定代理来解决。最简单的办法就是在npm命令上加参数,如下:npm --proxy http://127.0.0.1:8087 install -g phantomjs因为我用的是goagent代理,所以代理服务器的地址是http://127.0.0.1:8087,其它地址同理。原创 2014-03-11 22:07:11 · 2548 阅读 · 0 评论 -
npm install time出现gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedi
npm install time出现gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead错误的解决方案:出现这个错误的原因是因为安装的node是一个预览版,即版本号后面带-pre,如下:#node -vv0.10.22-pre解决办法就是安装一原创 2014-01-02 12:46:12 · 2136 阅读 · 0 评论 -
async waterfall步骤出错后的重试
var async = require("async");var i = 0;var state = {};async.waterfall([function thisstep1(cb) { state.step1 = thisstep1; state.step1cb = cb; console.log("func1, ", i); cb原创 2014-05-22 14:38:14 · 2015 阅读 · 0 评论