Search code examples
node.jsdependencieslodash

Is lodash built into Node?


This works without lodash installed as dependency:

const _ = require('lodash');
_.each([1,2,3],console.log);

(no, I have no lodash installed globally)

I saw somewhere something like nodejs supports lodash by default, but now I cannot find any documentation about this. Is it finally true? Where can I read about it?

P.S. Finally I found and deleted node_modules in my home directory, and all the magic gone, now this script produces an error for missing dependency. Thank you guys for help in this investigation.


Solution

  • I think Akrion is partially correct in what he is saying (not needing lodash anymore, lodash not being part of node by default).

    My guess as to why its working, is that you have a required library that in turn has a dependency on lodash and whatever bundler you are using is picking it out that way.

    I would hazard a guess here to say that if you open your node_modules folder lodash is sitting there. Take a squizz through your package.lock file (or yarn lock file) and see what is including lodash.

    EDIT As discovered through the comments, there was a node_modules folder in a home directory