title: Why does npm install local packages in my home directory?
body: <p>Node.js newbie here, Windows 10. I <code>npm install</code>-ed some packages (without <code>-g</code>) while inside a directory that didn't have <code>package.json</code>. npm placed the packages in <code>C:\Users\{MyName}\node_modules\</code>.</p>
  
  <p>Now I'm seeing some weird behavior:</p>
  
  <ul>
  <li>When I'm in my project directory (has <code>package.json</code> but no <code>node_modules/</code> yet), <code>npm list</code> and <code>npm list -g</code> both show an empty list</li>
  <li>When I'm in a non-project directory (no <code>package.json</code>)...
  
  <ul>
  <li><code>npm list -g</code> still shows an empty list</li>
  <li>However, <code>npm list</code> shows everything in <code>C:\Users\{MyName}\node_modules\</code></li>
  </ul></li>
  </ul>
  
  <p>Question 1. What is going on here? Apparently, <a href="https://docs.npmjs.com/files/folders" rel="noreferrer">npm's default global path should be <code>C:\Users\{MyName}\AppData\Roaming\npm\</code></a>. If so, why is it using <code>C:\Users\{MyName}\node_modules\</code>?</p>
  
  <p>Question 2. How do I get out of this mess? Node.js has no problem importing packages from <code>C:\Users\{MyName}\node_modules\</code>, but I want npm to list them properly. How can I delete the semi-global packages, reinstall them correctly, and ensure that this doesn't happen again?</p>