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())
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!