title: How to force npm to flatten dependencies?
body: <p>I have a project in which several frontends sharing a common lib.</p>
  
  <p>The module dependencies of those projects are managed by npm.</p>
  
  <p>So, in the package.json of each of those projects I have :</p>
  
  <pre><code>  "dependencies": {
      "mylib": "file:../&lt;...path...&gt;/mylib",
      ...other deps...
    },
  </code></pre>
  
  <p>I use "mylib" for two purposes :</p>
  
  <ul>
  <li>share some classes ;</li>
  <li>share common dependencies (mostly, angular)</li>
  </ul>
  
  <p>Until now, I was using npm 3.3.12 and after running <code>npm install</code>, the angular dependencies of mylib where right under the node_modules directory of my top level projects.</p>
  
  <p>So, I had for instance</p>
  
  <pre><code>node_modules
      @angular
          core
          common
          ....
      mylib
  </code></pre>
  
  <p>Now, with npm 5.4.2, I have :</p>
  
  <pre><code>node_modules
      mylib
          node_modules
              @angular
                  core
                  common
  </code></pre>
  
  <p>This causes a lot of problems in my build process.It requires additional configuration of typescript, by adding directives such as :</p>
  
  <pre><code>"baseUrl": "",
  "paths": {
      "@angular/common": ["node_modules/mylib/node_modules/@angular/common/"],
      "@angular/core": ["node_modules/mylib/node_modules/@angular/core/"],
      "@angular/compiler": ["node_modules/mylib/node_modules/@angular/compiler/"],
      "@angular/compiler-cli": ["node_modules/mylib/node_modules/@angular/compiler-cli/"],
      "@angular/forms": ["node_modules/mylib/node_modules/@angular/forms/"],
      "@angular/http": ["node_modules/mylib/node_modules/@angular/http/"],
      "@angular/platform-browser": ["node_modules/mylib/node_modules/@angular/platform-browser/"],
      "@angular/platform-browser/animations": ["node_modules/mylib/node_modules/@angular/platform-browser/animations/"],
      "@angular/platform-browser-dynamic": ["node_modules/mylib/node_modules/@angular/platform-browser-dynamic/"],
      "@angular/router": ["node_modules/mylib/node_modules/@angular/router/"],
      "primeng/primeng": ["node_modules/mylib/node_modules/primeng/primeng"],
      "rxjs/Rx": ["node_modules/mylib/node_modules/rxjs/Rx"]
      }
  </code></pre>
  
  <p>in tsconfig.json</p>
  
  <p>It becomes really annoying when you have to do similar configurations for AOT, rollup, etc...</p>
  
  <p>I tried to use npm dedupe do simplify this. As the projects have a lot of dependencies, it takes over 10mn for just one of them :</p>
  
  <pre><code>npm dedupe
  ...
  ...
  removed 824 packages and moved 1020 packages in 623.196s
  </code></pre>
  
  <p>Is there a standard, <em>efficient</em> way to have the same kind of dependencies flattening as before ? npm dedupe does the job, but takes so much time that it is not an acceptable alternative.</p>