installation process:NPM INSTALL-GD Expressnpm install-g express-generatorexpress-v//view version, now generally 4.x seriesExpress Ejs MyApp//Create a Ejs template projector Express myapp//this creates a jade template that has been successfully tested, whether Jade,ejs can be accessed through the following methods. //Enter the App.js file for modification:App.use (Express.static (Path.join (__dirname, ' Public ' ));
changed to: App.use (express.static (Path.join (__dirname, ' views ' )); / * View engine Setup environment variable settings, modified to the above situation, the following can not be modified, under normal circumstances can not modify * /app.set (' views ', Path.join (__dirname, ' views '));var Ejs = require (' Ejs ');app.engine ('. html ', ejs.__express);App.set (' View engine ', ' html ');The original 3 lines of this can be replaced;The following actions are followed:CD MyAppNPM Install//installation dependentNPM Start//Turn on serverEnter bin/www modify port to:Browser Input: http://localhost can access, at the same time, in the Views folder to write HTML can also be written in the address bar: http://localhost/hello.html such forms to access. since the above path has been modified, you should pay attention to the problem of css/js/img these paths in the background development. due to the system default access to public, if the requirements of security can be tested after the views to public, so the path needs to be noted:/javascripts/style.js Yes, is to add a/, while you are in the editor is required. /public/specific is what reason, I also do not know, may be the server different reason.
Under Nodejs Express from installation to operation of the entire process