According to @anatoliy's solution, on MacOS X I found search paths that perform
require('module')._resolveLookupPaths('myModule')
so i get allowed search paths
[ 'myModule', [ '/Users/admin/.node_modules', '/Users/admin/.node_libraries', '/usr/local/lib/node' ] ]
whereas
require('module')._resolveFilename('myModule')
won't allow the module that I was looking for anyway, actually the crazy thing is that _load won't solve the module:
> require('module')._load('myModule') Error: Cannot find module 'myModule' at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at repl:1:19 at sigintHandlersWrap (vm.js:32:31) at sigintHandlersWrap (vm.js:96:12) at ContextifyScript.Script.runInContext (vm.js:31:12) at REPLServer.defaultEval (repl.js:308:29) at bound (domain.js:280:14) at REPLServer.runBound [as eval] (domain.js:293:12) at REPLServer.<anonymous> (repl.js:489:10)
and require will be:
> require('myModule')
but i don't have this module in
myProject/node_modules/ myProject/node_modules/@scope/ /usr/local/lib/node_modules/ /usr/local/lib/node_modules/@scope /usr/local/lib/node_modules/npm/node_modules/ /usr/local/lib/node_modules/npm/node_modules/@scope $HOME/.npm/ $HOME/.npm/@scope/
so where is this module ???
First I had to do $ sudo /usr/libexec/locate.updatedb Then after some coffee I made locate myModule or better locate myModule/someFile.js
et voilĂ , it turns out that it was in the parent folder of my project, that is, outside the project root folder:
$pwd /Users/admin/Projects/Node/myProject $ ls ../../node_modules/myModule/
therefore, you cannot avoid rm -rf ../../node_modules/myModule/ and the new npm install .
I can argue that no one instructed npm scan my computer in search of modules in a place other than the root folder of the project where it was supposed to run or in the default search path.