Nodejs express automatically generates project framework

1. Install two modules
express and express-generator globally.
Enter on the command line:
npm install -g express
npm install -g express-generator
If the download of the module is slow, you can add Taobao's mirror in the space behind --registry= https:// registry.npm.taobao.org smile
express is not an internal or external command, nor is it a runnable program or batch file Reason:
http://blog.csdn.net/zzwwjjdj1/article/details/52127317
Check if the global installation of express is successful Command: express –version or express -h
write picture description here
If you see the version number, the installation is successful.
2. Generate the basic framework of the project
Command : express xxx, the default page template engine of the 4.x version of express is jade,
if you want to use ejs, the command should be It's like this: express -e xxx
write picture description here
3. Download the modules required for the project
Automatically create a folder, and then run the command in the red circle: cd hello && npm install
means to enter the hello directory, npm install is required to download the project The basic module, which is defined in the dependencies of the package.json file
write picture description here
4. Run the project
command : npm start
write picture description here
Browser access: http://localhost:3000/
write picture description here
5. Look at
write picture description here
www under the project structure bin is the project entry
node_moduls The modules required by the project are
public static resources, such as pictures, js, css
routes routing file
views page file
app.js project Basic configuration such as required middleware
package.json defines the basic information of the project, including the module name and version number required by the project

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326170261&siteId=291194637