Nodejs's Express usage notes

Source: Internet
Author: User

---restore content starts---

Learning Nodejs for almost one weeks, have not been how to contact before, and now learn to be fresh and exciting; when the get to the new point, in the sigh of knowledge abstruse, but also a fresh sense of accomplishment in it.

The first day when I began to learn node, will only follow the gourd painting scoop, the book said to install Express, then I said in accordance with the book, the book said to use the-G global installation, I also do. The previous one in the same sublime folder under the new multiple. js file to test the demo on the book, and then through the SFTP last to the remote server, run on the remote server. Today, unconsciously learning to Ejs's view template language, need to new mapping a folder (named "Ejs") to test the new demo, just start to show that Express is not available, so I am in the current folder ("Ejs" After the path is re-installed via NPM this NODEJS management tool after installing Express (NPM Install-g Express), looking at the files in the directory without adding anything, the post-installation information is displayed as follows:

Visual inspection only installs the above files in the/usr/lib/node_modules/express directory, but in this directory, it is still not possible to invoke the core module of Express. The reason for setting Expres to-G is because, in the actual production process, when we want to automatically generate an app package, we need to use the Express app (the project package that quickly generates the app in the current directory), or use Express ( Path) (quickly generate a package for an app project under the specified directory).

If you install Express with NPM installed Express, there will be an extra Node_modules folder in the path, there will be an express module file, when the runtime will not error. Therefore, when these core modules are installed under the project path, their files are automatically saved to the Node_modules directory under the current directory. Output as follows:

The Node_modules/express folder is generated under the current path and the file for the above list is generated.

Things like Body-parser, Cookies-parser, and so on that are used in other middleware can be installed in this project by using the command NPM install Middlewarename (middleware name) in the project root directory. Thus referenced in the project. The structure diagram for the installation is as follows:

The Body-parser folder is generated under the Node_modules directory, and the files for the above list are generated.

Then in production, if we need to use Express pathName (pathname), the structure directory of the app will be generated quickly, and there will be a default configuration. As shown in the following:

will automatically produce a default structure of the project, all of the directory structure is the default, each file has a default configuration.

I have a question about this: how to map the Remote app project directory to the sublime above--then use the sublime sftp "DownLoad Folder" to copy all the files under the mapped remote directory to the local mapping directory.

Done done~

Https://github.com/expressjs/express#quick-start

---restore content ends---

Nodejs's Express usage notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.