Reputation: 9429
Command of npm install <module>
installs modules always user home directory not purposely. Which setting causes this behavior?
I simply want to install modules to the current path. If I try to install a module, in a folder that in the Desktop for instance, it installs to home directory.
mymac:testfolder myuser$ pwd
/Users/myuser/Desktop/untitledfolder
mymac:testfolder myuser$ npm install async
npm http GET https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/lodash
[email protected] ../../node_modules/async
└── [email protected]
as you see, it installs the modules to ../../node_modules/
. I do not have package.json file in testfolder.
Upvotes: 3
Views: 674
Reputation: 111316
You need to have package.json in you current directory.
Did you run npm init
?
If you don't have package.json in your current directory then it may try find it in the upper directory, find in your home and install modules there.
Upvotes: 4