In Node.js how can I tell the path of `this` module?

As david van brink mentioned in the comments, the correct solution is to use __dirname. This global variable will return the path of the currently executing script (i.e. you might need to use ../ to reach the root of your module).

For example:

var path = require("path");
require(path.join(__dirname, '/models'));

Just to save someone from a headache.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)