Wednesday, April 19, 2017

Nodejs Express Generator

Next, let's install express-generator by running this command "npm i express-generator -g --no-optional" 

I'm ruunning nodejs in windows 7, so I need that --no-optional flag in order to prevent fsevent error message :D

After installing express-generator, we can see it's folder inside node-modules like this 
Next.... Let's test our express generator by running 'express -h' like this :

Ok... Let's create our first express-generator project 'express myFirstExpGen'
After running that command, we can see our directory content like this :
Btw,, actually we can specify view engine by using --v=pug|jade|ejs and etc. We also can specify css engine by using --c=less|stylus|sass|compass.... In this post I'm using default engine so it will be jade for view and plain css for css.

Next, let's run 'npm install' for installing project dependencies..

Last... Let's run our express, for windows, we can use this command :
'set DEBUG=projectDirName:* & npm start'

And then open localhost:3000 
Yeeei.... btw.... www file inside of  bin directory is our starting project file, and that file loads app.js.

Aaaand in this default project, we already have /users so if we open the page we will gonna see something like this :
It's content :

No comments:

Post a Comment