title: Tell NPM to install in different directory
body: <p>I have a situation where due to the requirements/opinion of a project I'm working with, I have to keep my <code>package.json</code> file in a nested directory. See below:</p>
  
  <pre><code>/my-app
    |-- /functions
      |-- /node_modules
      |-- package.json
  </code></pre>
  
  <p>The problem I have run into several times now is that I run <code>npm i &lt;package&gt;</code> from within <code>/my-app</code> and not <code>/my-app/functions</code> without realizing it and I end up spending time unnecessary time debugging my app because I installed the package in the wrong place.</p>
  
  <p>Is there a way to create a root-level <code>package.json</code> file that merely tells NPM, "hey, if you're going to install something, do it in this other directory."? For example:</p>
  
  <pre><code>/my-app
    |-- package.json &lt;-- add this
    |-- /functions
      |-- /node_modules
      |-- package.json
  </code></pre>
  
  <p>And maybe the <code>package.json</code> file within the root directory would look something like this?</p>
  
  <pre><code>{
    "installDirectory": "/functions"
  }
  </code></pre>
  
  <p>This functionality may already exist, but I was unable to find it in the documentation. The <code>--prefix</code> flag is similar, but it doesn't automatically handle the case I'm describing.</p>