NodeJS Express GetStarted
Express is web framework like Rails.
The latest version(2015/04/) is 4.x. 3.x and 4.x are different.
If you don’t have node in your env. Please install node first.
In Mac case, this is an entry(NodeJS Get started in Mac OS X)
We need 2 packages
npm install -g express npm install -g express-generator
Create Express Application
To create Express4 Application Template, we can use express-generator
application is your application name
By default, express application is Jade template.
If you want to use EJS, add -e option
express -e application
Eclipse and Nodejs plugin, WebStorm etc…
Debug and Start application from IDE, and set break point. Those are the points.
In my opinion, WebStorm is very good. WebStorm is not free.
I tried trial version first(30days).
WebStrom has import feature, and you can import express template application project in your WebStrom
By default, Express4 application doesn’t have any server listen parts.
We need to add listen part.
Please add following codes before module.exports.
// Start app.listen(3000); module.exports = app;
To start application, type command
app.js is main codes in Express.
This is main parts of express codes.
package.json is dependency node modules management file. This is like Gemfile in Rails
views is view file directory. You can put jade, ejs, view file in here.
You can access view file in express application
node_modules is dependencies module directory. We saved modules in here.
routes is route decision directory. You write route and route action in here.
How to learn?
Express Web page is helpful for you(here).