resolve: doesn't support `$HOME/.node_modules` or `$HOME/.node_libraries`
Hi, thanks for this module! It seems to have trouble finding my packages, though:
$ readlink -m ~/.node_modules
/mnt/…/nodejs/modules
$ nodejs -e 'console.log(require.resolve("lodash")); require("resolve")("lodash", console.log);'
/mnt/…/nodejs/modules/lodash/lodash.js
{ Error: Cannot find module 'lodash' from '.'
at /mnt/…/nodejs/modules/resolve/lib/async.js:50:31
at processDirs (/mnt/…/nodejs/modules/resolve/lib/async.js:184:39)
at ondir (/mnt/…/nodejs/modules/resolve/lib/async.js:199:13)
at load (/mnt/…/nodejs/modules/resolve/lib/async.js:82:43)
at onex (/mnt/…/nodejs/modules/resolve/lib/async.js:107:17)
at /mnt/…/nodejs/modules/resolve/lib/async.js:12:69
at FSReqWrap.oncomplete (fs.js:152:21) code: 'MODULE_NOT_FOUND' }
So require.resolve was able to find it, but resolve wasn’t. However, it works when I create a symlink /mnt/…/nodejs/node_modules to modules.
Update: Work-around: It also works when I pass option { paths: [process.env.HOME + "/.node_modules"] }
Update 2: However, in that case I have to then explicitly resolve the returned path in order to get the exact same result.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 30 (16 by maintainers)
Commits related to this issue
- [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` Note, this is a rarely used feature that should be aggressively avoided, but it‘s important to minimize gaps between... — committed to browserify/resolve by ljharb 2 years ago
- [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` Note, this is a rarely used feature that should be aggressively avoided, but it‘s important to minimize gaps between... — committed to browserify/resolve by ljharb 2 years ago
- [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` Note, this is a rarely used feature that should be aggressively avoided, but it‘s important to minimize gaps between... — committed to browserify/resolve by ljharb 2 years ago
- [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` Note, this is a rarely used feature that should be aggressively avoided, but it‘s important to minimize gaps between... — committed to browserify/resolve by ljharb 2 years ago
- [New] add default support for `paths` to include `$HOME/.node_{modules,libraries}` (#273) Note, this is a rarely used feature that should be aggressively avoided, but it‘s important to minimize gaps ... — committed to browserify/resolve by ljharb 2 years ago
The current workaround for this is to pass
[$HOME/.node_libraries, $HOME/.node_modules]as thepathsoption.However, what I can provide, is to say I didn’t write anything about
NODE_PATHSin the example repo. Alsogit grep -nFe NODE_PATHcame back empty, so it hasn’t crept in.Yes, if you run
demo.shin an environment similar enough to the GitHub Actions env.You’ll need GNU coreutils 8.21 or later installed. Ubuntu ships it by default, so I use that in the GitHub Actions.
Done in the
no-preserve-symlinksbranch, results are in.Nope, doesn’t seem to help: