title: Why use peer dependencies in npm for plugins?
body: <p>Why does, for example, a Grunt plugin define its dependency on grunt as "<strong>peer dependencies</strong>"?</p>
  
  <p>Why can't the plugin just have Grunt as its own dependency in <strong>grunt-plug/node_modules</strong>?</p>
  
  <p>Peer dependencies are described here: <a href="https://nodejs.org/en/blog/npm/peer-dependencies/" rel="noreferrer">https://nodejs.org/en/blog/npm/peer-dependencies/</a></p>
  
  <p>But I don't really get it.</p>
  
  <p><strong><em>Example</em></strong></p>
  
  <p>I'm working with AppGyver Steroids at the moment which uses Grunt tasks to build my source files into a /dist/ folder to be served on a local device. I'm quite new at npm and grunt so I want to fully comprehend what is going on.</p>
  
  <p>So far I get this:</p>
  
  <p><strong>[rootfolder]/package.json</strong> tells npm it depends on the <code>grunt-steroids</code> npm package for development:</p>
  
  <pre><code>  "devDependencies": {
      "grunt-steroids": "0.x"
    },
  </code></pre>
  
  <p>Okay. Running npm install in <strong>[rootfolder]</strong> detects the dependency and installs grunt-steroids in <strong>[rootfolder]/node_modules/grunt-steroids</strong>.</p>
  
  <p>Npm then reads <strong>[rootfolder]/node_modules/grunt-steroids/package.json</strong> so it can install <code>grunt-steroids</code> own dependencies.:</p>
  
  <pre><code>"devDependencies": {
      "grunt-contrib-nodeunit": "0.3.0",
      "grunt": "0.4.4"
    },
  "dependencies": {
      "wrench": "1.5.4",
      "chalk": "0.3.0",
      "xml2js": "0.4.1",
      "lodash": "2.4.1"
    },
  "peerDependencies": {
      "grunt": "0.4.4",
      "grunt-contrib-copy": "0.5.0",
      "grunt-contrib-clean": "0.5.0",
      "grunt-contrib-concat": "0.4.0",
      "grunt-contrib-coffee": "0.10.1",
      "grunt-contrib-sass": "0.7.3",
      "grunt-extend-config": "0.9.2"
    },
  </code></pre>
  
  <p>The "<strong>dependencies</strong>" packages are installed into <strong>[rootfolder]/node_modules/grunt-steroids/node_modules</strong> which is logical for me. </p>
  
  <p>The "<strong>devDependencies</strong>" aren't installed, which I'm sure is controlled by npm detecting I'm just trying to use <code>grunt-steroids</code>, and not develop on it.</p>
  
  <p>But then we have the "<strong>peerDependencies</strong>".</p>
  
  <p>These are installed in <strong>[rootfolder]/node_modules</strong>, and I don't understand why there and not in <strong>[rootfolder]/node_modules/grunt-steroids/node_modules</strong> so that conflicts with other grunt plugins (or whatever) are avoided?</p>