Category Archives: Nodejs

Node.js Resource

Stack Overflow Documentation

Tutorials

Developer Sites

Videos

Screencasts

Books

Courses

Blogs

Podcasts

JavaScript resources

Node.js Modules

Other

First, learn the core concepts of Node.js:

Then, you’re going to want to see what the community has to offer:

The gold standard for Node.js package management is NPM.

Finally, you’re going to want to know what some of the more popular packages are for various tasks:

Useful Tools for Every Project:

  • Underscore contains just about every core utility method you want.
  • Lo-Dash is a clone of Underscore that aims to be faster, more customizable, and has quite a few functions that underscore doesn’t have. Certain versions of it can be used as drop-in replacements of underscore.
  • TypeScript makes JavaScript considerably more bearable, while also keeping you out of trouble!
  • JSHint is a code-checking tools that’ll save you loads of time finding stupid errors. Find a plugin for your text editor that will automatically run it on your code.

Unit Testing:

  • Mocha is a popular test framework.
  • Vows is a fantastic take on asynchronous testing, albeit somewhat stale.
  • Expresso is a more traditional unit testing framework.
  • node-unit is another relatively traditional unit testing framework.
  • AVA is a new test runner with Babel built-in and runs tests concurrently.

Web Frameworks:

  • Express.js is by far the most popular framework.
  • Koa is a new web framework designed by the team behind Express.js, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs.
  • sails.js the most popular MVC framework for Node.js, and is based on express. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture.
  • Meteor bundles together jQuery, Handlebars, Node.js, WebSocket, MongoDB, and DDP and promotes convention over configuration without being a Ruby on Rails clone.
  • Tower (deprecated) is an abstraction of top of Express.js that aims to be a Ruby on Rails clone.
  • Geddy is another take on web frameworks.
  • RailwayJS is a Ruby on Rails inspired MVC web framework.
  • Sleek.js is a simple web framework, built upon Express.js.
  • Hapi is a configuration-centric framework with built-in support for input validation, caching, authentication, etc.
  • Trails is a modern web application framework. It builds on the pedigree of Rails and Grails to accelerate development by adhering to a straightforward, convention-based, API-driven design philosophy.
  • Danf is a full-stack OOP framework providing many features in order to produce a scalable, maintainable, testable and performant applications and allowing to code the same way on both the server (Node.js) and client (browser) sides.
  • Derbyjs is a reactive full-stack JavaScript framework. They are using patterns like reactive programming and isomorphic JavaScript for a long time.
  • Loopback.io is a powerful Node.js framework for creating APIs and easily connecting to backend data sources. It has a Angular.js SDK and provides SDKs for iOS and Android.

Web Framework Tools:

Networking:

  • Connect is the Rack or WSGI of the Node.js world.
  • Request is a very popular HTTP request library.
  • socket.io is handy for building WebSocket servers.

Command Line Interaction:

  • minimist just command line argument parsing.
  • Yargs is a powerful library for parsing command-line arguments.
  • Commander.js is a complete solution for building single-use command-line applications.
  • Vorpal.js is a framework for building mature, immersive command-line applications.
  • Chalk makes your CLI output pretty.

Work with streams:

Others:

Node lesson
Growth: 全栈增长工程师指南
refer:http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js

eclipse搭建Node.js开发环境(windows)

=>安装工具和插件:

1、安装eclipse
地址: http://www.eclipse.org/downloads/

2、安装nodeclipse插件:
Name:nodeclipse
Location:http://www.nodeclipse.org/updates

3、javascript编辑插件 — VJET
更新地址:http://download.eclipse.org/vjet/updates-0.10

4、google V8插件(调试必备)
更新地址:http://chromedevtools.googlecode.com/svn/update/dev/

5、【html编辑器】
下载地址:http://sourceforge.jp/projects/amateras/downloads/57710/tk.eclipse.plugin.htmleditor_2.2.0.jar/

=>安装框架:

1、安装supervisor

Node.js为了提高性能会读取缓存中的文件,为了调试方便,supervisor 会监视你对代码的改动,并自动重启 Node.js 。

打开cmd命令窗口,输入npm install -g supervisor即可。

2、安装Express

Express是目前最稳定、使用最广泛,而且是Node.js官 方推荐的唯一一个 Web 开发框架。

安装方式:打开cmd命令窗口,输入npm  install  -g  express 即可。

校验是否安装成功命令:express –V,会输出版本号。

3、安装express-generator

如果不安装express-generator,会提示“’express’ 不是内部或外部命令,也不是可运行的程序或批处理文件。”

是因为最新express4.0版本中将命令工具分出来了(项目地址:https://github.com/expressjs/generator)

安装方式:打开cmd命令窗口,输入npm install -g express-generator即可。

=>创建工程:

1) New》Node Project,命名为helloworld。

2) 打开 cmd 切换到helloworld 目录的上级目录,输入 express helloworld。

3) 切换到helloworld目录下,输入npm install 安装所需模块

4)配置Eclipse的Nodeeclipse属性。

选择Windows》Preferences》Nodeeclipse

Node.js path:  X:\nodejs\node.exe

Express path:C:\Users\{username}\AppData\Roaming\npm\express.cmd

5)npm start启动服务 或 在eclipse中Run as Node Application
如果在eclipse无法运行,请参照Nodejs app fails to run in Nodeclipse

6) 在浏览器中输入http://localhost:3000 验证

refer:

eclipse搭建Node.js开发环境http://www.yl-blog.com/article/243.html

express不是内部或外部命令http://jingyan.baidu.com/article/922554468a3466851648f419.html

Eclipse下Nodejs项目配置步骤  http://blog.csdn.net/ygh_0912/article/details/9108541

Modern Web Development

A list of technologies for modern web development.

Introduction

With this article I want to share a compilation of some well known top technologies that can be used today to develop a modern web application. The web development world has changed a lot because of its adaptation to the mobile and social media context, and a lot of new technologies, including servers, databases, development frameworks, and libraries have emerged to help us to  resolve several new problems and challenges.

Background

If you are a project manager, an architect, or a developer, you must choose the appropriate server, database,  language, framework or library for the design and implementation of the entire architecture or for some modules of your modern web application. This article references some of the principal and more used technologies that can help you to achieve this.

Servers

Nginx

Ngin is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Unlike traditional servers, Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.

http://wiki.nginx.org/Main

NodeJs  

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

http://nodejs.org 

Databases

MongoDb

MongoDB (from “humongous”) is an open-source  document database, and the leading NoSQL database, designed for ease of development and scaling. Instead of storing data in tables as is done in a “classical” relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.

http://www.mongodb.org 

Redis

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. In its outer layer, the Redis data model is a dictionary where keys are mapped to values. One of the main differences between Redis and other structured storage systems is that values are not limited to strings.

http://redis.io 

General purpose Frameworks / Libraries

Backbone.JS

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

http://backbonejs.org 

Underscore.Js

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It’s the tie to go along with jQuery’s tux, and Backbone.js’s suspenders.

 http://documentcloud.github.com/underscore 

Sencha frameworks

Sencha creates development frameworks and tools that help you design,  develop, and deploy applications for desktop and mobile devices. Their  goal is to enhance your development experience and final results by  providing well-structured, Web standards-based frameworks and tools that make drafting functional UI and CSS3 animations a breeze, and cloud  services for supporting your application available anytime, anywhere.

http://www.sencha.com/

Zepto.Js

Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. If you use jQuery, you already know how to use Zepto.

http://zeptojs.com

Angular JS

HTML enhanced for web apps! HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your  application. The resulting environment is extraordinarily expressive, readable, and quick to develop.

http://angularjs.org

Bootstrap

Sleek, intuitive, and powerful front-end framework for faster and easier web development. Bootstrap utilizes LESS CSS, is compiled via Node, and is managed through GitHub to help nerds do awesome stuff on the web. Bootstrap was made to not  only look and behave great in the  latest desktop browsers (as well as IE7!), but in tablet and smartphone browsers via responsive CSS as well.

http://twitter.github.io/bootstrap

Specific Libraries

Modernizr

Modernizr is a small JavaScript library that detects the availability of native implementations for next-generation web technologies, i.e. features that stem from the HTML5 and CSS3 specifications. Many of these features are already implemented in at least one major browser (most of them in two or more), and what Modernizr does is, very simply, tell you whether the current browser has this feature natively implemented or  not.

http://modernizr.com

Knockout

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically  (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and  maintainably.

http://knockoutjs.com 

Require.Js

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments,  like Rhino and Node. Using a modular script loader like RequireJS will  improve the speed and quality of your code.

http://requirejs.org 

Amplify Js

AmplifyJS solves the following problems:

  • AJAX Request Management: amplify.request provides a clean and elegant request abstraction for all types of data, even allowing for transformation prior to consumption.
  • Client Side Component Communication : amplify.publish/subscribe provides a clean, performant API for component to component communication.
  • Client Side Browser & Mobile Device Storage : amplify.store takes the  confusion out of HTML5 localStorage. It doesn’t get simpler than using amplify.store(key, data)! It even works flawlessly on mobile devices.
http://amplifyjs.com 

Moment.Js

A 4.8k JavaScript date library for parsing, validating, manipulating, and formatting dates.

http://momentjs.com 

D3 JS

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful  visualization components and a data-driven approach to DOM manipulation. http://d3js.org 

Breezze 

Breeze is a JavaScript library that helps you manage data in rich client applications. If you store data in a relational database, query and save those data as complex object graphs, and share these graphs across multiple screens of your JavaScript client, Breeze is for you.

http://www.breezejs.com/home 

Mongoose JS

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.  Woks fine with Node JS.

http://mongoosejs.com 

Meta -Languages

CoffeScript   

CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

 http://coffeescript.org 

TypeScript

TypeScript is a language for application-scale JavaScript development. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source.

http://www.typescriptlang.org

Less

The dynamic stylesheet language. LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions.LESS runs on both the server-side (with Node.js and Rhino) or client-side (modern browsers only).

http://lesscss.org 

Application containers

PhoneGap (Apache Cordova)  

Is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores. PhoneGap leverages web technologies developers already know best… HTML and JavaScript.

http://www.phonegap.com 

AppCelerator

Create rich native iOS, Android, hybrid, and mobile web apps from a single JavaScript-based SDK. Titanium empowers you to choose the right way to reach your end users on any device.

http://www.appcelerator.com 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

from:http://www.codeproject.com/Reference/597538/Modern-Web-Development

nodejs 快速入门

node.js开发指南.pdf

 

开篇:如果你还不知道Node.js是什么,那么你可以先看看这篇:Node.js 究竟是什么?或者任何关于它的介绍。

第一步:安装Node.js

Node官网下载安装包进行安装(这里使用的是Windows环境)

安装完成后进入cmd输入”node+ender“测试是否安装成功

PS:两次ctrl+c退出node

第二步:安装全局支持包

仍然是在cmd中输入以下命令(注意:一定要退出node)

npm install express@3.26 -g  //express是node中最常用的web框架,如果安装不了则更改镜像,命令:npm set registry http://registyr.npmjs.org

npm install nodemon -g //nodemon用于实时监听app.js文件

npm install grunt-cli -g  //grunt是一款任务构建工具,可以使用它完成自动编译/压缩等工作

npm install bower -g   //bower是一款页面引入文件管理工具

PS:npm是node的包管理器,使用它安装/卸载支持包非常方便

PS:安装完成后,均可以通过输入”包名称 – h“测试是否安装成功及查看使用帮助

第三步:创建Web项目

使用命令或手动在相应磁盘下创建用于放置项目的文件夹(cmd命令大全)

这里使用的是本机D盘下的apps文件夹

执行”express APPNAME“命令,进行项目创建(这里以TEST作为项目名称)

PS:public中是我们熟悉的images、javascript、CSS

PS:routes是路由文件

PS:views中视图文件,express默认使用的模板引擎是jade

第四步:完善项目架构

  使用任意的文本编辑器打开package.json文件,可以看到:

项目中已经有了express和jade,但我们想要完成项目,这些还远远不够,

我们会需要像watch、less、copy等等这样的包来进行辅助

你可以像我一样直接把它们全部写入到这个文件里,像这样:

当然:你也可以根据自己的需要,一个个进行安装,但记得在你的npm命令中不需要再使用 -g 了

好了,现在执行”cd appname && npm install“命令

PS:很明显,它的意思是进入项目的同时检测package.json文件安装里面列举出的所有包

  PS:这样是不是很省事儿,免去了一条条的npm install …命令

好的,接下来,你需要创建一个”Gruntfile.js“文件放在package.json的同级目录下,

你可以把这里的代码拷贝,做一些相应的改动即可

它用于控制那些需要执行的包,比如它们:

第五步:规范化前端引入文件

  前端总会因为各种原因,而需要引入一些文件支持

我们熟悉的就有jQueryBootstraphtml5shivrespond

这些文件愈多,当我们管理、更换版本时就愈不方便

这时,前面安装的bower就起到作用了,可以这么做:

在public文件夹下创建”bower.json“文件

它的写法就像这样:——代码你可以在bower官网首页找到

紧接着,再创建”.bowerrc“文件控制它们的存放目录(比如放到当前目录的libs文件夹下)

里面写上这么一条就行:

好嘞,现在在该目录下执行”cd public && bower install“命令

原理还是那样:进入public的同时检测bower.json文件,下载所有列举的文件,放入.bowerrc文件指定的目录

第六步:启动

使用cmd在app.js文件所在位置,执行”nodemon app.js“命令

这时,就可以在浏览器中输入 localhost:3000 来试试你的成果了

如果,你希望改动了某些文件(比如coffe、less等)后,会自动进行编译等操作,

那得再开启grunt的监听:

新开一个cmd,执行”grunt watch“命令,像这样:

PS:想要执行watch命令,一定要安装相应的包哦 ^_^

 

总结:在Node.js下搭建项目,难免会跟大量的包打交道,搞清楚它们的作用,按需使用。

参考:
How to install Node.js and NPM on Windows

Node.js Get Started and Miscellaneous

Basics of Node.js for MEAN Stack Development
from:http://www.cnblogs.com/prolifes/articles/3659623.html