node – how to find source file location of a module

To find the file location for a node module require('module')._resolveFilename can be used. Here is quick code snippet and its outcome.

file = require('module')._resolveFilename('react')
console.log("react file location=" + file)


react file location=/usr/lib/node_modules/react/react.js
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments