playing Node.js: 1. basic concepts18 Oct 2012
These days, I wanna have a look at the hot and smart technology: Node.js. So I’d like to make some notes and share some useful resources.
The package manager for Node.js. npm for Node.js is as apt-get for Ubuntu.
How to install it?
I’m not talking about how to do it in Windows, because it’s bringing ourselves into troubles. Use one of the techniques from gist: 579814 is just good and ok. After following that,
node shoule be avaiable as the command in the shell.
package.json file? And what’s a
Every Node.js project should provide one of these. It describes the dependencies and some other information of the project. See one example.
node_modules is the floder of the local dependency files.
There are two excelent posts explaining them. Node.js, Require and Exports, Node.js, Module.Exports and Organizing Express.js Routes. The follwing should be read before reading the second post here.
Why should I use it?
How to use it?
A framework for devloping Node.js websites.
npm install email@example.com -g for global usage. Create a folde and run
express --css stylus to get a hello world example. Then
npm install to install the dependencies locally. Run
node app to view the website!
What’s a “middleware”?
“Middleware” is an important concept for Express framework, and Connect, the framework that Express is based on. In short, a request sent to Express apps (or/and the response) is handled, modified, ‘filtered’ by the middlewares, in order.
In fact, I think Node.js is still young, and its concepts are unfamiliar to most of us. It’s good toy, however it should be carefully considered if we want to use it in production.