Tuesday, 4 April 2017

Get absolute path to Node.js core module

I am looking for help on how to get the absolute path to a core module on the filesystem

the problem I am seeing is that require.resolve(), when called on a core module, literally just prints out the name of the core module, not the absolute path to the module code, e.g.

console.log(require.resolve('cluster')) => 'cluster'
console.log(require.resolve('assert')) => 'assert'

how can I get the full/absolute path to the core module on my filesystem?

The reason I need this is because I am looking to bundle several core modules for the browser. I may have to use surrogates/polyfills for these instead, but we shall see.



via Alexander Mills

No comments:

Post a Comment