Node.js · Junior · Question 20 of 75
Where does require("lodash") look for the package?
- 1Only in a global folder installed with
npm -g - 2On the npm website, downloading it on the fly
- ✓Correct answer: In the
node_modulesfolder of the current directory, then in each parent directory up to the root
Explanation
Node.js walks up the directory tree looking in each node_modules. Packages installed with -g are not found by require() by default.