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)

Outcome:

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

Comments

Click here to write/view comments