Yarn: Support local file dependencies without file protocol

Created on 11 Oct 2016  ·  13Comments  ·  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
bug

What is the current behavior?
In a number of my projects I have a package.json with dependencies as such:

dependencies: {
    "babel-preset-something": "../ui-babel-preset-something",
}

yarn fails:

> yarn
yarn install v0.15.0
info No lockfile found.
[1/4] 🔍  Resolving packages...
error Couldn't find package "babel-preset-something" on the "npm" registry.
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

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

> cd yarn-test
> ls
> mkdir a b
> cd a
> ~/.yarn/bin/yarn.js init
yarn init v0.15.0
question name (a):
question version (1.0.0):
question description:
question entry point (index.js):
question git repository:
question author:
question license (MIT):
success Saved package.json
✨  Done in 1.97s.
> cd ../b
> ~/.yarn/bin/yarn.js init
yarn init v0.15.0
question name (b):
question version (1.0.0):
question description:
question entry point (index.js):
question git repository:
question author:
question license (MIT):
success Saved package.json
✨  Done in 1.88s.
> ~/.yarn/bin/yarn.js add ../a
yarn add v0.15.0
info No lockfile found.
[1/4] 🔍  Resolving packages...
error Couldn't find package "../a" on the "npm" registry.
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

What is the expected behavior?

Expected behavior is that running yarn installs the package into node_modules.

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

  • node v6.2.0
  • yarn 0.15.0
  • OSX 10.11.3
cat-bug cat-compatibility

Most helpful comment

@montogeek Compatibility is absolutely a priority. I'll mark this issue as a bug so we can get this fixed for the next release.

All 13 comments

Try setting the protocol as file://

Change

dependencies: {
    "babel-preset-something": "../ui-babel-preset-something",
}

to:

dependencies: {
    "babel-preset-something": "file:../ui-babel-preset-something",
}

And this should work. Wasn't aware that npm had these semantics for bare paths.

It is possible to keep it compatible with npm?

@montogeek Compatibility is absolutely a priority. I'll mark this issue as a bug so we can get this fixed for the next release.

Adding the prefix file: to relative paths works. Thanks for the heads up.

bump. v0.19 series is released but there is no words from the team. cc @kittens

yarn 1.0.1 still attempting to pull packages from remote even if they exist in the filesystem.

@mikemaccana can you open a new issue and detail what exactly is broken with reproduction steps?

@BYK Sorry I can't right now. The broken node Docker images (even when I trash /opt/node and /usr/local/bin node) won't properly upgrade to yarn 1.0.1 - it installs but global bin is broken. I've had to revert to 0.27.1 after wasting far too much time trying to fix it. Sorry.

@mikemaccana just tagged 1.0.2 so may be it will help?

~Yarn doesn't seem to pull in dependencies of file:... packages~ nevermind, my file: package didn't have the dep I expected!

Removing file: prefix solved a problem we had where yarn install on windows would add ./ prefix to relative file paths, but yarn install on macOS would remove it. We were both using yarn version 1.3.2.

"Since v0.21.0 release, file: prefix is not needed. See pull-request with fix and changelog." - Piotr Lewandowski on stackoverflow

I am having this issue on 1.13.0

Was this page helpful?
0 / 5 - 0 ratings