iLemming
iLemming

Reputation: 36274

Is there a way to find where node loads a module from?

Is there a way to find path to a module after it's been required?

So my problem is - I start node repl, and require('stylus') it loads it from somewhere.

I did npm cache clean, rm -rf node_modules, npm uninstall -g stylus, etc. yet it still successfully loads it from somewhere.

Upvotes: 2

Views: 30

Answers (1)

Daniel
Daniel

Reputation: 38849

Use require.resolve('stylus'). That will give you the path to the module, but will not import it.

So in the REPL.

> require.resolve('stylus');

You can also reference module.filename from inside the module itself if you ever have the need for that.

Upvotes: 3

Related Questions