Skip to content

Instantly share code, notes, and snippets.

@Unitech
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save Unitech/e46e0d914d0f9c62f739 to your computer and use it in GitHub Desktop.

Select an option

Save Unitech/e46e0d914d0f9c62f739 to your computer and use it in GitHub Desktop.
console.log(__filename);
console.log(module.filename);
console.log(module.parent);
console.log(module.children);
console.log(__dirname);
console.log(module)
console.log(process.env.PWD)
console.log(require.main.filename)
console.log(require.main === module)
>>> node test/fixtures/path-check.js
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
null
[]
/Users/shant/keymetrics/PM2/test/fixtures
{ id: '.',
exports: {},
parent: null,
filename: '/Users/shant/keymetrics/PM2/test/fixtures/path-check.js',
loaded: false,
children: [],
paths:
[ '/Users/shant/keymetrics/PM2/test/fixtures/node_modules',
'/Users/shant/keymetrics/PM2/test/node_modules',
'/Users/shant/keymetrics/PM2/node_modules',
'/Users/shant/keymetrics/node_modules',
'/Users/shant/node_modules',
'/Users/node_modules',
'/node_modules' ] }
/Users/shant/keymetrics/PM2
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
true
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
null
[]
/Users/shant/keymetrics/PM2/test/fixtures
{ id: '.',
exports: {},
parent: null,
filename: '/Users/shant/keymetrics/PM2/test/fixtures/path-check.js',
loaded: false,
children: [],
paths:
[ '/Users/shant/keymetrics/PM2/test/fixtures/node_modules',
'/Users/shant/keymetrics/PM2/test/node_modules',
'/Users/shant/keymetrics/PM2/node_modules',
'/Users/shant/keymetrics/node_modules',
'/Users/shant/node_modules',
'/Users/node_modules',
'/node_modules' ] }
/Users/shant/keymetrics/PM2
/Users/shant/keymetrics/PM2/test/fixtures/path-check.js
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment