title: NPM incorrect dependency resolution order
body: <p>I'm working on a ReactJS application, which is failing to start for me with auto-generated <code>package-lock.json</code>. However, it's running fine on production and also locally for my colleague. The error I'm getting when running <code>npm start</code>:</p>
  <pre><code>./node_modules/react-datepicker/es/index.js
  8297:8-17 'react-popper' does not contain an export named 'Reference'.
  </code></pre>
  <p>package-lock.json:</p>
  <pre><code>...
  &quot;react-datepicker&quot;: {
      &quot;version&quot;: &quot;2.1.0&quot;,
      &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-datepicker/-/react-datepicker-2.1.0.tgz&quot;,
      &quot;integrity&quot;: &quot;sha512-zsPqierShVc0NN+JCyJO18jMFDTbGNSgmekQm+Zr5JYH/aZShsjOBGQmjNiQmIw7nJNQDRzh1oQUND3TY/9Swg==&quot;,
      &quot;requires&quot;: {
          &quot;classnames&quot;: &quot;^2.2.5&quot;,
          &quot;date-fns&quot;: &quot;^2.0.0-alpha.23&quot;,
          &quot;prop-types&quot;: &quot;^15.6.0&quot;,
          &quot;react-onclickoutside&quot;: &quot;^6.7.1&quot;,
          &quot;react-popper&quot;: &quot;^1.0.2&quot;
      },
      &quot;dependencies&quot;: {
          &quot;react-popper&quot;: {
              &quot;version&quot;: &quot;1.3.3&quot;,
              &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-popper/-/react-popper-1.3.3.tgz&quot;,
              &quot;integrity&quot;: &quot;sha512-ynMZBPkXONPc5K4P5yFWgZx5JGAUIP3pGGLNs58cfAPgK67olx7fmLp+AdpZ0+GoQ+ieFDa/z4cdV6u7sioH6w==&quot;,
              &quot;requires&quot;: {
                  &quot;@babel/runtime&quot;: &quot;^7.1.2&quot;,
                  &quot;create-react-context&quot;: &quot;&lt;=0.2.2&quot;,
                  &quot;popper.js&quot;: &quot;^1.14.4&quot;,
                  &quot;prop-types&quot;: &quot;^15.6.1&quot;,
                  &quot;typed-styles&quot;: &quot;^0.0.7&quot;,
                  &quot;warning&quot;: &quot;^4.0.2&quot;
              }
          }
      }
  },
  &quot;reactstrap&quot;: {
      &quot;version&quot;: &quot;6.5.0&quot;,
      &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/reactstrap/-/reactstrap-6.5.0.tgz&quot;,
      &quot;integrity&quot;: &quot;sha1-umVeMmRuJiGCn2H6oDPmB+xmJOU=&quot;,
      &quot;requires&quot;: {
          &quot;classnames&quot;: &quot;^2.2.3&quot;,
          &quot;lodash.isfunction&quot;: &quot;^3.0.9&quot;,
          &quot;lodash.isobject&quot;: &quot;^3.0.2&quot;,
          &quot;lodash.tonumber&quot;: &quot;^4.0.3&quot;,
          &quot;prop-types&quot;: &quot;^15.5.8&quot;,
          &quot;react-lifecycles-compat&quot;: &quot;^3.0.4&quot;,
          &quot;react-popper&quot;: &quot;^0.10.4&quot;,
          &quot;react-transition-group&quot;: &quot;^2.3.1&quot;
      }
  },
  &quot;react-popper&quot;: {
      &quot;version&quot;: &quot;0.10.4&quot;,
      &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-popper/-/react-popper-0.10.4.tgz&quot;,
      &quot;integrity&quot;: &quot;sha1-rypBXqIike3VBGeNev2opu4ylao=&quot;,
      &quot;requires&quot;: {
          &quot;popper.js&quot;: &quot;^1.14.1&quot;,
          &quot;prop-types&quot;: &quot;^15.6.1&quot;
      }
  }
  ...
  </code></pre>
  <p>I believe the error above is caused by the fact that <code>react-datepicker</code> instead of using <code>react-popper@1.3.3</code> as per its sub-dependencies, uses <code>react-popper@0.10.4</code> defined at the root level. After updating <code>package-lock.json</code> as below, the error is gone (note that root <code>react-popper@0.10.4</code> is moved to <code>reactstrap</code> sub-dependencies)</p>
  <pre><code>...
  &quot;reactstrap&quot;: {
      &quot;version&quot;: &quot;6.5.0&quot;,
      &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/reactstrap/-/reactstrap-6.5.0.tgz&quot;,
      &quot;integrity&quot;: &quot;sha1-umVeMmRuJiGCn2H6oDPmB+xmJOU=&quot;,
      &quot;requires&quot;: {
          &quot;classnames&quot;: &quot;^2.2.3&quot;,
          &quot;lodash.isfunction&quot;: &quot;^3.0.9&quot;,
          &quot;lodash.isobject&quot;: &quot;^3.0.2&quot;,
          &quot;lodash.tonumber&quot;: &quot;^4.0.3&quot;,
          &quot;prop-types&quot;: &quot;^15.5.8&quot;,
          &quot;react-lifecycles-compat&quot;: &quot;^3.0.4&quot;,
          &quot;react-popper&quot;: &quot;^0.10.4&quot;,
          &quot;react-transition-group&quot;: &quot;^2.3.1&quot;
      },
      &quot;dependencies&quot;: {
          &quot;react-popper&quot;: {
              &quot;version&quot;: &quot;0.10.4&quot;,
              &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-popper/-/react-popper-0.10.4.tgz&quot;,
              &quot;integrity&quot;: &quot;sha1-rypBXqIike3VBGeNev2opu4ylao=&quot;,
              &quot;requires&quot;: {
                  &quot;popper.js&quot;: &quot;^1.14.1&quot;,
                  &quot;prop-types&quot;: &quot;^15.6.1&quot;
              }
          }
      }
  },
  &quot;react-datepicker&quot;: {
      &quot;version&quot;: &quot;2.1.0&quot;,
      &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-datepicker/-/react-datepicker-2.1.0.tgz&quot;,
      &quot;integrity&quot;: &quot;sha512-zsPqierShVc0NN+JCyJO18jMFDTbGNSgmekQm+Zr5JYH/aZShsjOBGQmjNiQmIw7nJNQDRzh1oQUND3TY/9Swg==&quot;,
      &quot;requires&quot;: {
          &quot;classnames&quot;: &quot;^2.2.5&quot;,
          &quot;date-fns&quot;: &quot;^2.0.0-alpha.23&quot;,
          &quot;prop-types&quot;: &quot;^15.6.0&quot;,
          &quot;react-onclickoutside&quot;: &quot;^6.7.1&quot;,
          &quot;react-popper&quot;: &quot;^1.0.2&quot;
      },
      &quot;dependencies&quot;: {
          &quot;react-popper&quot;: {
              &quot;version&quot;: &quot;1.3.3&quot;,
              &quot;resolved&quot;: &quot;http://packages.je-labs.com/npm/private-npm/react-popper/-/react-popper-1.3.3.tgz&quot;,
              &quot;integrity&quot;: &quot;sha512-ynMZBPkXONPc5K4P5yFWgZx5JGAUIP3pGGLNs58cfAPgK67olx7fmLp+AdpZ0+GoQ+ieFDa/z4cdV6u7sioH6w==&quot;,
              &quot;requires&quot;: {
                  &quot;@babel/runtime&quot;: &quot;^7.1.2&quot;,
                  &quot;create-react-context&quot;: &quot;&lt;=0.2.2&quot;,
                  &quot;popper.js&quot;: &quot;^1.14.4&quot;,
                  &quot;prop-types&quot;: &quot;^15.6.1&quot;,
                  &quot;typed-styles&quot;: &quot;^0.0.7&quot;,
                  &quot;warning&quot;: &quot;^4.0.2&quot;
              }
          }
      }
  }
  
  ...
  </code></pre>
  <p>From what I understand about npm packages resolution, dependencies are resolved started from the bottom of the tree so the initial 'package-lock.json' should be perfectly fine. Tried running it with node v10, v11, and v12, and in all cases got the same error. As it's running fine for my colleague and also on production, I'm assuming this must be related to my local environment but can't figure out the root cause of the error.</p>