0

How do I get it so that node modules install into the current directory?

I have tried to google it and it says that simply running:

npm install

Should work. But this seems to always install to the user's home directory. How do I change this?

Thanks.

X0r0N
  • 1,816
  • 6
  • 29
  • 50
  • 1
    Do you have package.json? What is the content? – aadarshsg Jun 22 '15 at 06:53
  • if you enter `pwd` in the terminal ? You are in the project folder or home folder ? – throrin19 Jun 22 '15 at 07:06
  • I am in the correct directory when I run pwd. I don't have a package.json that was the problem. I didn't realise if package.json is missing, it stores in the default directory. I assumed if it was missing it would create it (if you don't use the -g flag) – X0r0N Jun 22 '15 at 07:25
  • possible duplicate of [npm install module in current directory](http://stackoverflow.com/questions/14032160/npm-install-module-in-current-directory) – Mohit Jun 22 '15 at 07:31
  • @Mohit I disagree. That other needs to be updated to show that npm can install to 1 of 3 directories. 1. Using -g flag put it in a system folder available to all users on the system 2. Missing package.json installs to users home folder. 3. If package.json exists, it install to the working directory. – X0r0N Jun 22 '15 at 07:35
  • 1
    `npm init` will help you create the package.json interactively :) – Rockyy Jun 22 '15 at 08:18

1 Answers1

0

Needed package.json file. Otherwise it will use the default node_modules folder... On my system it was set to user home folder.

X0r0N
  • 1,816
  • 6
  • 29
  • 50