+ 2
Why __dirname is undefined
Hi, I am working on a nodejs website and I have added ("type": "module") in the package.json file so I can use the ES6 (from ... import ... ) syntax but when I try to console.log (__dirname) it tells me that it is *undefined* so why is that??
2 Answers
+ 1
This might help you
https://nodejs.org/docs/latest-v12.x/api/esm.html#esm_no_node_path
+ 3
From definition
-A variable that has not been assigned a value is of type undefined .
-A method or statement also returns undefined if the variable that is being evaluated does not have an assigned value.
- A function returns undefined if a value was not returned .