Do you want to request a feature or report a bug?
_bug_
What is the current behavior?
$ yarn add whatever
yarn add v0.27.5
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@scope%2fb: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/private/tmp/yarn-issue/packages/a/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
If the current behavior is a bug, please provide the steps to reproduce.
git clone https://github.com/aymericbeaumet/yarn-workspace-add-package.git /tmp/yarn-issue
cd /tmp/yarn-issue/packages/a
yarn add whatever
What is the expected behavior?
@scope/b
should be found as it exists in the workspacewhatever
should be added as a dependency of the @scope/a
packagePlease mention your node.js, yarn and operating system version.
node 6.10.2
yarn 0.27.5
osx 10.12.5
In the rfc has some notes about workspace
command to do that
yarn worspace <package-name> add <dependency>
But I tried in a project and it's doesn't work anyway :sad:
But I tried in a project and it's doesn't work anyway :sad:
What's happening on your side?
I just tried yarn workspace <package-name> add <dependency>
, and it seems to work, but the <dependency>
is added at the root _package.json_, instead being appended to the <package>
_package.json_. I'm not sure that's the expected behaviour.
Tha's happened with me too, <dependency>
was add on package.json
at root. I think that's is a bug, because the package dependency should added on it package.json
, right?!
because the package dependency should added on it
package.json
, right?!
Yep it should π, here is the updated bug report
Do you want to request a feature or report a bug?
_bug_
What is the current behavior?
$ yarn workspace '@scope/a' add whatever
yarn workspace v0.27.5
yarn add v0.27.5
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@scope%2fb: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/private/tmp/yarn-issue/packages/a/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/bin/node
Arguments: /usr/local/bin/yarn add whatever
Directory: /private/tmp/yarn-issue/packages/a
Output:
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
If the current behavior is a bug, please provide the steps to reproduce.
git clone https://github.com/aymericbeaumet/yarn-workspace-add-package.git /tmp/yarn-issue
cd /tmp/yarn-issue/packages/a
yarn workspace '@scope/a' add whatever
What is the expected behavior?
@scope/b
should be found as it exists in the workspacewhatever
should be added as a dependency of the @scope/a
packagePlease mention your node.js, yarn and operating system version.
node 6.10.2
yarn 0.27.5
osx 10.12.5
This should be fixed on 1.2.1 - can someone confirm?
@BYK It works as expected on 1.2.1
it works as expected but i cannot add local package as a dev dependency.
when running yarn workspace '@scope/a' add whatever -D
, the -D argument is stripped away
any argument after the package name is stripped away
This continues to be an issue as of yarn 1.3.2
$ yarn add @scope/b
yarn add v1.3.2
[1/4] π Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@scope%2fb: Not found".
Project structure
scope-root/package.json
{ "name": "@scope/root", "version": "1.0.0", "private": true, "workspaces": ["packages/*"] }
scope-root/packages/module-a/package.json
{ "name": "@scope/a", "version": "1.0.0", "private": true }
scope-root/packages/module-b/package.json
{ "name": "@scope/b", "version": "1.0.0", "private": true }
Issuing either of the following will fail with the "not found" error:
scope-root/packages/module-a/
: yarn add @scope/b
scope-root/
: yarn workspace @scope/a add @scope/b
As commented on previously, one would expect either case to work with or without the -D
flag, and @scope/b
should be appended to the dependencies of @scope/a
.
The only workaround is manually editing scope-root/packages/module-a/package.json
, then inserting "@scope/b": "1.0.0"
as a dependency (or devDependency), and finally running yarn
. But none of that should be necessary.
@Aaike cd
to the workspace of choice then yarn add package --dev
.
Still broken in current master
(v1.4.1). It looks like yarn add
and yarn workspace add
check the npm registry, not local workspace packages:
~/Projects/yarn-test π yarn workspaces info
yarn workspaces v1.4.1
{
"frontend": {
"location": "packages/frontend"
},
"x_totally_not_real": {
"location": "libs/x_totally_not_real"
}
}
β¨ Done in 0.08s.
~/Projects/yarn-test π yarn workspace frontend add x_totally_not_real
yarn workspace v1.4.1
yarn add v1.4.1
[1/4] π Resolving packages...
error Couldn't find package "x_totally_not_real" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Command failed.
Exit code: 1
however if you just use yarn install
then it works fine:
~/Projects/yarn-test π rm -rf node_modules/
~/Projects/yarn-test π yarn install
yarn install v1.4.1
[1/4] π Resolving packages...
[2/4] π Fetching packages...
[3/4] π Linking dependencies...
[4/4] π Building fresh packages...
success Saved lockfile.
β¨ Done in 0.24s.
~/Projects/yarn-test π ls -l node_modules/
total 24
lrwxr-xr-x 1 user LOCAL\Domain Users 20 Feb 20 08:20 frontend -> ../packages/frontend
lrwxr-xr-x 1 user LOCAL\Domain Users 26 Feb 20 08:20 x_totally_not_real -> ../libs/x_totally_not_real
The problem is worse if you local package matches the name of an actual published library, because that will get installed instead of your local one. i.e. if you have a workspace package names base
and try to yarn add base
then it will download the actual base
library from NPM, not use your local workspace one.
@flagello Unfortunately, running yarn add
from inside a workspace breaks Yarn hooks (e.g. patch-package
) that normally run inside the root directory.
It would be best to just run yarn <workspace> add -D <package>
(where yarn <workspace>
is a shortcut script for yarn workspace <workspace>
that one can use today)
@dinvlad yarn workspace <workspace> add -D <package>
should be yarn workspace <workspace> add <package> -D
.
Still, as of v1.3.2
, yarn workspace <workspace> add <package> --dev
adds <package>
to the workspaceβs dependencies
rather than its devDependencies
(#5396).
@flagello any reason for the exact ordering? after all, regular yarn add
accepts both -D <package>
and <package> -D
forms.
Alternatively, we could use yarn --cwd <workspace> add <package> -D
(if that worked properly), but that probably deserves another issue.
Sorry @dinvlad, I forgot to mention yarn workspace <workspace> add -D <package>
specifically fails with Missing list of packages to add to your project.
I did not attempt to reproduce elsewhere. Might be related to these outstanding issues?
@flagello ah yes, I recall that happened to me to. Thanks for pointing this out. Both variants should work once a fix is implemented, IMO
One thing that might be related (if anyone can confirm) I have the same issue trying to run a global add from a workspace (trying to global install a workspace module)
I tried these from the workspace folder:
yarn workspace <workspace> global add .
yarn workspace <workspace> global add <workspace>
yarn global add .
None of those worked. Got the same error, yarn tries to get the local package dependencies from yarnpkg registry getting an error of malformed response.
yarn 1.6.0
macOS 10.13.4
node 9.3
Still, as of
v1.3.2
,yarn workspace <workspace> add <package> --dev
adds<package>
to the workspaceβsdependencies
rather than itsdevDependencies
(#5396).
I believe yarn workspace <workspace> -- add <package> --dev
should work. The --
is necessary to split the yarn workspace
options and the yarn add
options.
In fact, I've tried yarn workspace <workspace> add -D <package>
and that works too with Yarn 1.5.1
I'm using Lerna monorepo with yarn.
I can't do yarn add somepkg
because yarn always wants resolve my local packages through npm
registry ;(
v1.13.0
Please, fix it somehow ;((((
I've tried yarn workspace
yarn workspace @scope/a add @scope/[email protected]
error An unexpected error occurred: "https://registry.yarnpkg.com/@scope%2fb: Not found".
Thanks in advance for any help!
Same problem for me
Using yarn 1.220: workspaces + lerna
yarn workspace <workspace> add <package> -D
or any variant above always adds as dependency
However, if I use lerna add <package> --dev --scope <workspace>
it properly adds to devDependencies.
Lerna is using Yarn to install it, but not sure what the underlying difference is. Here's output from running above lerna command:
info cli using local version of lerna
lerna notice cli v3.20.2
lerna info versioning independent
lerna notice filter including "my-site"
lerna info filter [ 'my-site' ]
lerna info Adding my-svelte-component-library in 1 package
lerna info bootstrap root only
yarn install v1.21.1
[1/4] π Resolving packages...
[2/4] π Fetching packages...
[3/4] π Linking dependencies...
[4/4] π¨ Building fresh packages...
β¨ Done in 11.11s.
edit: Just noticed that lerna is using different yarn version than what I get from running:
$ yarn --version
1.22.0
cd package/whatever; yarn add typescript --dev
yarn workspace whatever add typescript --dev
yarn workspace whatever -- add typescript --dev
yarn workspace whatever add typescript --dev
yarn workspace v1.22.0
yarn add v1.22.0
info No lockfile found.
$ node ./internals/scripts/xcodecheck.js
[1/5] Validating package.json...
[2/5] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/local-dep: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/home/ericwooley/projects/project/whateveryarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Command failed.
Exit code: 1
Command: /home/ericwooley/.nvm/versions/node/v12.13.0/bin/node
Arguments: /home/ericwooley/projects/project/.yarn/releases/yarn-1.22.0.js add typescript --dev
Directory: /home/ericwooley/projects/project/whatever
Output:
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
All broken on 1.22.0, 1.21.0, and 1.16.0 for me in ubuntu and osx.
Manually adding packages is very annoying :(
I got this error when my paths were with ./
"workspaces": [
"./web",
"./desktop",
"./packages/*"
],
After I removed ./
everything worked
"workspaces": [
"web",
"desktop",
"packages/*"
],
I landed here searching for the error I got, and after trying a couple of solutions, I came up with another not yet described, it seems yarn
is taking into account the version of the packages in the monorepo, so if instead of just trying to add them we append @<version>
, it works.
This doesn't work
$ yarn add @myscope/package
But adding the version works fine
This doesn't work
$ yarn add @myscope/[email protected]
I got this error when my paths were with
./
"workspaces": [ "./web", "./desktop", "./packages/*" ],
After I removed
./
everything worked"workspaces": [ "web", "desktop", "packages/*" ],
THANK YOU
I was trying to add expo-cli using yarn add -g expo-cli
but I had the error mentioned. When I used yarn add global expo-cli
it worked.
Most helpful comment
This continues to be an issue as of yarn 1.3.2
Project structure
Issuing either of the following will fail with the "not found" error:
scope-root/packages/module-a/
:yarn add @scope/b
scope-root/
:yarn workspace @scope/a add @scope/b
As commented on previously, one would expect either case to work with or without the
-D
flag, and@scope/b
should be appended to the dependencies of@scope/a
.The only workaround is manually editing
scope-root/packages/module-a/package.json
, then inserting"@scope/b": "1.0.0"
as a dependency (or devDependency), and finally runningyarn
. But none of that should be necessary.