NodeJS (i) Require path access

Source: Internet
Author: User
Require path
  • Current directory of relative paths:./xxx/xxx.js or./xxx/xxx.
  • Parent directory of Relative path:. /xxx/xxx.js or. /xxx/xxx.
  • Absolute path: F:/xxx/xxx.js or/xxx/xxx.js or/xxx/xxx.

?

In the directory structure, Mysql.js relative to the User.js directory is no longer available. /(relative to the parent directory),./(relative to the current directory).

PS: Used in Mysql.js. /means access to the file under the Routes folder,./means that the file under the Test folder is accessed.

So access to the project under Models/user.js should be so accessed, User.s relative to the parent directory (root directory) of Mysql.js parent directory (routes folder)

So the introduction is introduced in the following ways:. /.. /models/user

NodeJS (i) Require path access

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.