Home > Web Front-end > JS Tutorial > Detailed explanation of the steps to obtain the current execution path in nodejs

Detailed explanation of the steps to obtain the current execution path in nodejs

php中世界最好的语言
Release: 2018-05-21 15:31:29
Original
2735 people have browsed it

This time I will bring you nodejsDetailed explanation of the steps to obtain the current execution path, what are the precautions for nodejs to obtain the current execution path, the following is a practical case, let’s take a look .

process.cwd() The path of the currently executing program (the path when executing the command line, not the code path. For example, if node ./xxx/xxx/a.js is executed in the root directory, cwd returns the root directory Address)

dirname: The location where the code is stored

process.execPath: The currently executed node path (such as: /bin/node)

DEMO:

console.log(process.execPath)
console.log(dirname)
console.log(process.cwd())
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to php Chinese Other related articles online!

Recommended reading:

Detailed explanation of the use case of vue toast pop-up component

Detailed explanation of the steps of using nodeJs crawler

The above is the detailed content of Detailed explanation of the steps to obtain the current execution path in nodejs. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template