Skip to content Skip to sidebar Skip to footer

__dirname Is Not Defined In Node.js 10 Experimental?

I am using Node.js 10.0.0 & my index.mjs looks like: import path from 'path'; console.log(__dirname); In my terminal, I run node --experimental-modules index.mjs And I get t

Solution 1:

ESM is not node-specific, and node-specific "globals" (such as __dirname and module) will not work. import.meta is expected to provide a suitable replacement.

Source: GitHub issue.

Post a Comment for "__dirname Is Not Defined In Node.js 10 Experimental?"