Home > Web Front-end > JS Tutorial > body text

How to operate nodejs to obtain the current execution path

php中世界最好的语言
Release: 2018-05-30 09:58:58
Original
1460 people have browsed it

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!