Installing the same module under multiple relative paths fails on Linux

What I Wanted to Do

Have a multi-module project where modules refer to each other using relative file: paths.

What Happened Instead

Referring to the same module with different relative paths fails with Could not install from "../children/children/child-2" as it does not contain a package.json file. The path printed is wrong and contains a duplicate parent path.

Reproduction Steps

For me the output looks like this:

npm install
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../children/children/child-2" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-07-15T18_32_19_228Z-debug.log

Details

2019-07-15T18_32_19_228Z-debug.log (1.6 KB)

Platform Info

Only managed to reproduce on Linux, not on macOS.

$ npm --versions
<!-- paste output here -->

    {
      parent: '1.0.0',
      npm: '6.10.1',
      ares: '1.15.0',
      brotli: '1.0.7',
      cldr: '35.1',
      http_parser: '2.8.0',
      icu: '64.2',
      llhttp: '1.1.4',
      modules: '72',
      napi: '4',
      nghttp2: '1.38.0',
      node: '12.5.0',
      openssl: '1.1.1c',
      tz: '2019a',
      unicode: '12.1',
      uv: '1.29.1',
      v8: '7.5.288.22-node.14',
      zlib: '1.2.11'
    }

$ node -p process.platform
<!-- paste output here -->


    linux

Related looking existing issues:

Opened a pull request here: https://github.com/npm/cli/pull/217