Play node. js, don't play backstage that's killing the chicken sledgehammer, it's fine today. Experience of developing node. JS Backstage
1. First install node. js and CNPM, I'm not going to say it here, look at my other article in node. js Installation and Configuration
To install the Express framework:
sudo cnpm install express-g
Global Installation Express,
After installing the Express generator, you can install it with the following statement
sudo cnpm install-g express-generator
At this point you can enter
Express-v
Check out the version of the Express frame you've installed,
Open the folder where you want to put the project, enter
Express-File name
You can create a new Express project and then install dependent
CNPM Install
And then enter
NPM start
Start the project, open the browser, enter in the address bar
127.0. 0.1:
At this point, the page will display "Welcome express" words that you have been installed successfully,
Open Project under the View Discovery suffix name is jade, what situation, in fact, is similar to HTML, but looked uncomfortable, changed
Open App.js
// View engine Setupapp.set(' views ', ' views ') ) ); app. Set ('view engine'Jade');
Then replace this code with a
App.set('views '); App.engine ( ' HTML ' , ejs.__express); app. Set ('view engine'html');
Then change the name of the Jade suffix in the view to HTML.
Then install the Ejs module in the project directory
CNPM Install--save Ejs
Then enter NPM start to start the project
Of course it is best to install supervisor so that you do not need to restart the project every time the project has changed, install the Supervisor dependencies First, note that the global
CNPM Install Supervisor-g
Then open the Package.json and find
"Scripts": { "start": "Node./bin/www" },
Replace node with supervisor, which is the
" Scripts " : { "start""supervisor./bin/www" },
So you don't need to modify the project to restart the project
Configure the Express framework in node. js