Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file dependency's relative path resolution is different than npm's #973

Closed
unbornchikken opened this issue Oct 13, 2016 · 3 comments
Closed

Comments

@unbornchikken
Copy link

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I have a local module that is referenced by path in my application's package.json, e.g:

"co-main": "file:../CompanyModules/base/co-main/"

That co-main module depends on another company module that is reside an other directory. So in co-main's package.json has this:

"co-utils": "file:../co-utils"

So, for the better understanding, the directory structure is the following:

C:
|- Dev
    |- MyCoolApplication (co-main referenced there)
    |- CompanyModules
        |- base
            |- co-main (here lies co-main that references utils with file:../co-utils)
            |- co-utils

npm install runs fine, but yarn install fails with the following:

error "C:\\Dev\\co-utils" doesn't exist.

So the bug is obvious, yarn resolves co-main's relative path by using the main package.json's path (C:\Dev\MyCoolApplication), but npm uses the submodule's root path for relative resolution (C:\Dev\CompanyModules\base\co-main).

If the current behavior is a bug, please provide the steps to reproduce.

  1. Create an environment described above
  2. Run npm install, it gets succeeded
  3. Run yarn install, it gets failed with the above error

What is the expected behavior?

yarn resolves relative paths exactly like npm does.

Please mention your node.js, yarn and operating system version.

Windows 10, Node.js 4.6.0, yarn 0.15.1, npm 3.10.5

@leecade
Copy link

leecade commented Nov 2, 2016

any plan to support this key feature?

@ozsay
Copy link

ozsay commented Nov 16, 2016

loc = path.join(this.config.cwd, loc);

seems like the file resolver always resolves relative to cwd when the module path is not absolute. what it should do is resolve relative to the parent package (recursively).

looks like #1498 is solving this

@hpurmann
Copy link
Contributor

hpurmann commented Feb 18, 2017

Solved by #1498. I can confirm that this is fixed (macOS though). @kittens can you close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants