I need to know if it is possible to obtain the current execution node?
Example:
..html <script id="x"> console.log(document.currentNode.id); // << this must return "x" </script> ..html
Thanks!
__dirname: It is a local variable that returns the directory name of the current module. It returns the folder path of the current JavaScript file.
We can get the path of the present script in node. js by using __dirname and __filename module scope variables. __dirname: It returns the directory name of the current module in which the current script is located. __filename: It returns the file name of the current module.
process. cwd() returns the current working directory, i.e. the directory from which you invoked the node command. __dirname returns the directory name of the directory containing the JavaScript source code file.
To get the absolute path of the current file/code. To get the name of the file currently executing.
Modern browsers support a standard property on document object that points to the current script node:
https://developer.mozilla.org/en-US/docs/DOM/document.currentScript
<script id="x"> console.log(document.currentScript.id); // << this must return "x" </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With