Do you want to request a feature or report a bug?
bug
What is the current behavior?
$ yarn global install .
yarn global v0.18.1
[1/4] Resolving packages...
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
(yarn assumes we're trying to install a yarnpkg/npm available package named "." which gets turned into undefined)
If the current behavior is a bug, please provide the steps to reproduce.
git clone any npm/yarn project
try running "yarn global add" or "yarn global add ."
compare results to "npm install -g" or "npm install -g ."
What is the expected behavior?
The package in the current working directory should be installed globally.
Please mention your node.js, yarn and operating system version.
$ for i in node yarn npm ; do echo -n "$i: "; $i --version ; done
node: v6.9.2
yarn: 0.18.1
npm: 3.10.9
yarn global add file:.?
@simonbuchan While that did not work, "yarn global add file:/absolute/path/to/project" did work.
neither "file:." nor "file:./" work from within the project, and "file:path/to/project" doesn't work when above the project in the tree. I'll adjust the title of this bug report to reflect that file: only seems to support absolute paths.
As a side note, it would probably be helpful to improve the error handling around those scenarios to better guide the user. The following is very misleading:
$ sudo yarn install -g .
yarn install v0.18.1
error `install` has been replaced with `add` to add new dependencies. Run "yarn global add ." instead.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
$ sudo yarn global add .
yarn global v0.18.1
warning No license field
[1/4] Resolving packages...
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
Hmm, non-global add works with relative file: (at least on node 6: see "File URLs ..." in https://github.com/npm/npm/releases/tag/v4.1.0).
It would be nice if yarn, like npm, detected path-like names (. or .. or contains /, but does not start with @?), but it looks like it's not documented for a reason, support is pretty flakey: https://github.com/yarnpkg/yarn/issues/2227
I reproduced this issue with yarn 0.19.1. I found this workaround:
yarn global add file:$PWD
$PWD is a bash variable that is always available that points to the current directory. In other words, it expands to absolute path that resolves to ".".
Thank you @markstos for your suggestion of yarn global add file:$PWD, worked perfect. I had this exact problem and reported at Install global package that is not published.
This is honestly a huge issue, and I can't believe more people don't have this question. WIth npm you can simply do npm install -g .
There is no documentation, or none that I could find about this on the global docs.
Most helpful comment
I reproduced this issue with yarn
0.19.1. I found this workaround:$PWDis a bash variable that is always available that points to the current directory. In other words, it expands to absolute path that resolves to ".".