node.js使用汇总贴

金天:学习一个新东西,就要持有拥抱的心态,如果固守在自己先前的概念体系,就会有举步维艰的感觉。
.NET程序员初用node.js最需要适应的就是异步开发,以及弱类型语言难以避免的拼写错误与弱小的语法提示。

本文作为使用node.js一路遇到的问题汇总,从一而终,持续更新。

1. 迷你书

Node.js

http://www.nodebeginner.org/index-zh-cn.html

node.js之看懂package.json依赖库版本控制

2. Mongoose, 作用类似于Entity Framework/Hiberanate. 学习一个新的框架或类库,最好的方式就是直接看源码或者官方API

http://mongoosejs.com/docs/guide.html

3. Promises

http://liubin.github.io/promises-book/

Node.js之Promise维护(同步)多个回调(异步)状态

4. Ubuntu 上安装node.js [选择版本]

https://github.com/nodesource/distributions#debinstall

sudo apt-get install -y build-essential
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs

5. 后台运行 forever / nohub / pm2

6. ubuntu环境下通过upstart管理node应用的自启动停止等

description "node application service"
start on startup
stop on shutdown
script
    chdir /var/yournodeapphome
    echo $$ > /var/run/yournodeapp.pid
    export ENV=local
    exec node app.js >> /var/log/yournodeapp.log 2>&1
end script

pre-start script
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/yournodeapp.log
end script
pre-stop script
    rm /var/run/yournodeapp.pid
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/yournodeapp.log
end script

比如起名yournodeapp.conf 复制到/etc/init/yournodeapp.conf

然后就可以通过upstart管理

status yournodeapp
start yournodeapp
stop yournodeapp

7. 一篇烧脑的JavaScript文章

http://www.cnblogs.com/xxcanghai/p/5189353.html

8. 检测nodejs是否运行在debug状态

Try checking if `global.v8debug` is defined or not. If it is, then 
you're in debug mode.
原文地址:https://www.cnblogs.com/jtbj/p/node_js_all_in_one.html