Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6743213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:56:04+00:00 2026-05-26T11:56:04+00:00

Is there way or library that could tell where from require’d module was resolved

  • 0

Is there way or library that could tell where from require’d module was resolved and especially what binaries it possibly contains?

For example, when I require(‘coffee-script’) there is (AFAIK) no way to tell its installation directory and what command line binaries it has.

What I ideally need is some kind of mix between require and package.json parser, e.g. like following hypotethical ‘npminfo’ library.

var npminfo = require('npminfo')

// get info about module
var pkginfo = npminfo.resolve('coffee-script')
pkginfo.version => '1.1.0'
pkginfo.path  => '/home/teemu/node_modules/coffee-script'
pkginfo.bins =>  { coffee: '/home/teemu/node_modules/coffee-script/bin/coffee', cake: '/home/teemu/node_modules/coffee-script/bin/cake'}

// generic info
npminfo.binpath => '/home/teemu/.node_modules/bin' 

I did try to use require.paths and just walk through directories, but for some reason it does not contain path where my modules are actually installed. Somehow require still finds them though?

~ $ node
> require.paths
[ '/Users/teemuikonen/.node_modules',
  '/Users/teemuikonen/.node_libraries',
  '/usr/local/lib/node' ]
>

~ $ ls /usr/local/lib/node
wafadmin

~ $ ls .node_modules/
ls: .node_modules: No such file or directory

~ $ ls node_modules/
cli  cradle coffee-script ...   

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:56:05+00:00Added an answer on May 26, 2026 at 11:56 am

    use require.resolve(‘module’) to get the path

    require looks for a folder called node_modules at each level. This isn’t displayed in require.paths(), but I’m not sure why.

    Update:
    this will log the files in the modules folder

    var fs = require('fs');
    var path = require('path');
    var path1 = require.resolve('module');
    path1 = path.dirname(path1);
    fs.readdir(path1, function(err, files){
      console.log(err);
      console.log(files);
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way or a library that can help me load assembly in
Is there any feasible way of using generics to create a Math library that
Question: Is there an easy way (library function) to perform a bitwise AND or
Is there any way or a library to get a system-wide (global) keyboard shortcut
Is there a standard way / C# library to convert a string into a
Is there a way for a shared library to be notified when it is
Is there a way to execute SQL custom functions with Enterpise Library? I've tried
Is there a way (a program, a library) to approximately know which language a
Is there a library/simple way to flip an image? Flip image like this: AABBCC
I was wondering if there was a way to use the boost library in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.