Do you want to request a _feature_ or report a _bug_?
bug
What is the current behavior?
Resolution of local modules fails. Suppose a repo like this:
modules/a <-- Package A
modules/b <-- Package B, depends on a (file:../a)
main/ <-- main Package, depends on b (file:../modules/b)
yarn (install) fails, because it tries to resolve _a_ with file:../a instead of file:../modules/a
If the current behavior is a bug, please provide the steps to reproduce.
made a example repo: https://github.com/ds82/yarn-test-local-modules
git clone https://github.com/ds82/yarn-test-local-modules
cd yarn-test-local-modules/main
yarn
error "/Users/dsaenger/code/yarn-test-local-modules/a" doesn't exist
What is the expected behavior?
yarn should resolve the correct path of local modules like npm does. _npm install works in the repo posted above_
Please mention your node.js, yarn and operating system version.
node v4.6, osx 10.10.5, yarn 0.15.1
this patch seems to fix the problem (but I consider it a hack ./. temporary workaround for me):
diff --git i/src/resolvers/exotics/file-resolver.js w/src/resolvers/exotics/file-resolver.js
index 134c0f7..e99180b 100644
--- i/src/resolvers/exotics/file-resolver.js
+++ w/src/resolvers/exotics/file-resolver.js
@@ -23,7 +23,13 @@ export default class FileResolver extends ExoticResolver {
async resolve(): Promise<Manifest> {
let loc = this.loc;
if (!path.isAbsolute(loc)) {
- loc = path.join(this.config.cwd, loc);
+ let cwd = this.config.cwd;
+
+ if (this.request.parentRequest && this.request.parentRequest.pattern) {
+ cwd = path.join(cwd, this.request.parentRequest.pattern.replace(/.*@(file\:)?/, ''));
+ }
+
+ loc = path.join(cwd, loc);
}
if (!(await fs.exists(loc))) {
throw new MessageError(this.reporter.lang('doesntExist', loc));
I have the exact same issue. Using your patch fixed it, though I did have to modify this -> _this for 0.15.1, installed on Windows via MSI:
C:\Program Files (x86)\Yarn\lib\resolvers\exotics\file-resolver.js
if (!path.isAbsolute(loc)) {
let cwd = _this.config.cwd;
if (_this.request.parentRequest && _this.request.parentRequest.pattern) {
cwd = path.join(cwd, _this.request.parentRequest.pattern.replace(/.*@(file\:)?/, ''));
}
loc = path.join(cwd, loc);
}
@nearwood: Thats because you edited the lib file and my patch is for the src file.
Solved by #1498. I can confirm that this is fixed. @torifat can you close?
Thank you! While at it, can you close the duplicate of this, https://github.com/yarnpkg/yarn/issues/973, as well? 馃槣