title: require.resolve not resolving dependency
body: <p>I was working on a node module, where I would have to check if the user had installed an specific package (that's the logic I have to follow) and if not, install that using <code>child_process.exec</code>.</p>
  
  <p>That's where the problem appears, even though my script installed the package (<code>node_modules</code> contains it, also <code>package.json</code>), if I call <code>require.resolve</code> again, it says the module does not exist.</p>
  
  <p>For what I found (from node github issues), node has sort of a "cache", where on the first call, if the package is not installed, the cache entry for this package is set to a random value which is not the path to it. Then when you install and try to call that again, it calls that cache entry.</p>
  
  <p>Is there any other way to check if packages are installed, or my local node installation is broken?</p>