`npm install express`
q.
When you install a module, it will put it in a node_modules folder inside your application directory. You can now require it like any built-in module.
q..
file: `static-file-server.js`
code:
var express = require('express'),
app = express();
app.use(express.static(__dirname + '/public'));
app.listen(8081);
execute: `node static-file-server.js`
## NPM
There are thousands of modules available that solve almost all typical problems that you're likely to encounter. Remember to check npm before re-inventing the wheel. It's not unheard of for a typical Node.js application to have dozens of dependencies.
In the previous example we manually installed Express. If you have a lot of dependencies, that's not going to be a very good way to install them. That's why npm makes use of a package.json file.
package.json
{
"name" : "MyStaticServer",
"version" : "0.0.1",
"dependencies" : {
"express" : "3.3.x"
}
}
A package.json file contains an overview of your application. There are a lot of available fields, but this is pretty much the minimum. The dependencies section describes the name and version of the modules you'd like to install. In this case I'll accept any version of Express 3.3. You can list as many dependencies as you want in this section.
Now instead of installing each dependency separately, we can run a single command and install all of them.
`$ npm install`
When you run this command npm will look in the current folder for a package.json file. If it finds one, it will install every dependency listed.
## Blogging Test Apps
- Wheat is a blogging engine that reads a git repo full of markdown articles and presents them as a website.
- A Simple Blog with CouchDB, Bogart, and Node.js
## Bogart Web Framework
## Frameworks
*
*
## Template Engines
Handlebars is one popular template engine.
Dust.js
## http GET and POST requests
#nodejs - #programming - #javascript - #howto