Hi, Ive noticed an issue that arises when using this package alongside npm link or yarn link - when resolving from a linked dependency's directory as basedir, this package will resolve to a module in the linked packages node_modules. This is in contrast to Node's require.resolve, which will resolve to the root level node_modules (same as if the package wasn't linked).
For example, if resolve-example depends on a package test-pkg, test-pkg itself depends on lodash, and I link resolve-example to test-pkg using yarn link, here's what I see after running the following
const resolve = require('resolve/sync')
let opts = { basedir: '/Users/jacksonchristoffersen/resolve-example/node_modules/test-pkg', preserveSymlinks: true }
console.log(require.resolve('lodash', opts))
// /Users/jacksonchristoffersen/resolve-example/node_modules/lodash/lodash.js
console.log(resolve('lodash', opts))
// /Users/jacksonchristoffersen/resolve-example/node_modules/test-pkg/node_modules/lodash/lodash.js
opts = { basedir: '/Users/jacksonchristoffersen/resolve-example/node_modules/test-pkg', preserveSymlinks: false }
console.log(require.resolve('lodash', opts))
// /Users/jacksonchristoffersen/resolve-example/node_modules/lodash/lodash.js
console.log(resolve('lodash', opts))
// /Users/jacksonchristoffersen/test-pkg/node_modules/lodash/lodash.js
I'd expect these results to match for each value of opts
Hi, Ive noticed an issue that arises when using this package alongside
npm linkoryarn link- when resolving from a linked dependency's directory asbasedir, this package will resolve to a module in the linked packagesnode_modules. This is in contrast to Node'srequire.resolve, which will resolve to the root levelnode_modules(same as if the package wasn't linked).For example, if
resolve-exampledepends on a packagetest-pkg,test-pkgitself depends onlodash, and I linkresolve-exampletotest-pkgusingyarn link, here's what I see after running the followingI'd expect these results to match for each value of
opts