This time I will show you how to operate nodejsGet the current execution path, operate nodejs to get the current execution pathWhat are the precautions, the following is a practical case, let’s take a look one time.
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:
How to use js to encapsulate ajax function and usage
How to operate vue in a custom component Enable v-model
The above is the detailed content of How to operate nodejs to obtain the current execution path. For more information, please follow other related articles on the PHP Chinese website!