Skip to content

Instantly share code, notes, and snippets.

@DanielHoffmann
Last active August 6, 2020 09:34
Show Gist options
  • Save DanielHoffmann/c57b57bbb41757fc6117bc5724c69fe5 to your computer and use it in GitHub Desktop.
Save DanielHoffmann/c57b57bbb41757fc6117bc5724c69fe5 to your computer and use it in GitHub Desktop.
const cwd = process.cwd()
module.exports = function requireResolve(moduleName) {
const resolveOpts = {
paths: [
// will prefer this folder:
path.resolve(cwd, '..', 'some-dep', 'node_modules'),
// over this folder:
path.resolve(cwd, 'node_modules'),
],
}
return require.resolve(moduleName, resolveOpts)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment