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

Yarn 1.0.1 workspaces does not work with scoped packages #4354

Open
screendriver opened this issue Sep 8, 2017 · 18 comments
Open

Yarn 1.0.1 workspaces does not work with scoped packages #4354

screendriver opened this issue Sep 8, 2017 · 18 comments

Comments

@screendriver
Copy link

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

bug

What is the current behavior?

It try to use the new workspaces feature. All my packages are scoped to a private scope @me/.... Unfortunately it does not work. I get the error Error: https://registry.yarnpkg.com/@me%2fbar: Not found

By the way: the packages are not deployed to npm at the moment. It only exist locally at the moment.

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

Just create a new project and call your packages @foo/...

What is the expected behavior?

Should link locally all packages (regardless if there are deployed or not)

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

Node 8.4.0
Yarn 1.0.1
macOS sierra

@jordaaash
Copy link

Same issue here. This worked in 0.28.4

@terrymunro
Copy link

Using the * notation in workspaces I also have this issue but specifically targeting each workspace works for me.

e.g. package.json

{
  "private": true,
  "workspaces": ["packages/*"]
}

Gives the same error.

But: package.json

{
  "private": true,
  "workspaces": ["packages/a", "packages/b", "packages/c"]
}

seems to work.

@BYK
Copy link
Member

BYK commented Sep 14, 2017

Is there a mini repo that I can clone and reproduce this behavior so we can debug?

@screendriver
Copy link
Author

The hint from @terrymunro works also in my case. If I replace "workspaces": ["src/*"] with "workspaces": ["src/one", "src/two", "src/three"] it works.

@ravicious
Copy link

That's interesting, I haven't observed this behavior. My packages are all scoped (let's say @foo/bar) and they're under the packages folder: packages/bar, packages/baz and so on. When migrating from yarn 0.27 to 1.0, all I had to do was to add "workspaces": "packages/*" to package.json.

Not trying to say that this issue is invalid or something, I'm just curious as to what is the culprit behind this problem in order to not fall into it in the future.

@screendriver
Copy link
Author

I tried to create a sample project but there it works 😳 In my project here at my company it does not work 🤔

@usulpro
Copy link

usulpro commented Sep 25, 2017

I faced this issue as well.
First, it was on node 7 with yarn 1.0.2, then I updated to node 8.5.0 with yarn 1.2.0 and it still doesn't work
If you're looking for a project to reproduce it, you can check out this one:
https://github.com/storybooks/react-cdk/tree/50a2aae859ee174c233d878291f536dabeb2d4e8

steps to reproduce:

git clone https://github.com/storybooks/react-cdk.git
cd react-cdk
git checkout workspaces-issue
yarn

it throws:

yarn install v1.1.0
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@storybook%2fcdk-scripts: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/home/usulpro/WebDev/_CDK/test/react-cdk/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

these packages aren't published yet

I tried to change packages/* to specific packages but without success

@usulpro
Copy link

usulpro commented Sep 25, 2017

solved by specifying the package version:

-"@storybook/cdk-scripts": "*"
+"@storybook/cdk-scripts": "^0.1.1-alpha"

@joefiorini
Copy link

joefiorini commented Oct 12, 2017

Can confirm this seems to be solving the same issue for me. I originally had specified "latest" everywhere I referenced my workspace packages. Going through and changing each instance to an actual version specifier (eg. ^1.0.0) fixed it.

@afenton90
Copy link

I can still reproduce this with [email protected].
I have:

  • scoped packages all deployed to npm registry.
  • all specified in the workspace root in workspaces.
  • "private": true in workspace route.

It does not seem to recognise that the package is within the workspace.

@egeriis
Copy link

egeriis commented Jun 15, 2018

This is still an issue in [email protected]

We have a curious case where it works in some environments, e.g. locally but not in cloud infra.

@rally25rs
Copy link
Contributor

Has anyone tested this in yarn 1.7.0? If i'm getting the package structure right, then this seems fixed?

~/Projects/yarn-test3 🐒   cat packages/pkgA/package.json
{
  "name": "@yarnpkg/pkgA",
  "version": "1.0.0"
}
~/Projects/yarn-test3 🐒   cat packages/pkgB/package.json
{
  "name": "@yarnpkg/pkgB",
  "version": "1.0.0",
  "dependencies": {
    "@yarnpkg/pkgA": "*"
  }
}
~/Projects/yarn-test3 🐒   yarn
yarn install v1.7.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...

success Saved lockfile.
✨  Done in 0.11s.

~/Projects/yarn-test3 🐒   ls -l node_modules/@yarnpkg/
total 16
lrwxr-xr-x  1 me  891112136  19 Jun 19 20:05 pkgA -> ../../packages/pkgA
lrwxr-xr-x  1 me  891112136  19 Jun 19 20:05 pkgB -> ../../packages/pkgB

@cbumstead
Copy link

Using the * notation in workspaces I also have this issue but specifically targeting each workspace works for me.

e.g. package.json

{
  "private": true,
  "workspaces": ["packages/*"]
}

Gives the same error.

But: package.json

{
  "private": true,
  "workspaces": ["packages/a", "packages/b", "packages/c"]
}

seems to work.

I had this same issue but for me it was because the package I was referencing was more than one level deep in the folder path and needed a globstar **

{
  "private": true,
   "workspaces": ["packages/**"]
 }

@tvvignesh
Copy link

Yup. I can confirm this as well. Adding a version works to the scoped package in package.json works. If I try with wildcard, it looks up in the registry. Any way we can fix this?

@rnd2442
Copy link

rnd2442 commented Sep 29, 2020

Adding a version works to the scoped package in package.json works. If I try with wildcard, it looks up in the registry

I have the same issue on yarn 1.22.5

@MikeCastillo1
Copy link

Yup. I can confirm this as well. Adding a version works to the scoped package in package.json works. If I try with wildcard, it looks up in the registry. Any way we can fix this?
Same issue, I'm trying to use with out scoped meanwhile but it the dependency is not being loaded from local package

@FirstVertex
Copy link

wtf

@jkhaui
Copy link

jkhaui commented Aug 23, 2021

Using the * notation in workspaces I also have this issue but specifically targeting each workspace works for me.
e.g. package.json

{
  "private": true,
  "workspaces": ["packages/*"]
}

Gives the same error.
But: package.json

{
  "private": true,
  "workspaces": ["packages/a", "packages/b", "packages/c"]
}

seems to work.

I had this same issue but for me it was because the package I was referencing was more than one level deep in the folder path and needed a globstar **

{
  "private": true,
   "workspaces": ["packages/**"]
 }

I don't really have anything of value to add to this issue, other than to say that this solution fixed everything for me after spending 2 entire days tearing my hair out.

This says to me that either:
a) I am a really bad developer, or
b) Workspaces desperately needs some clearer documentation outlining best practices and providing sample architectures, which would go some way to assuaging the attendant issues caused by the lack of said documentation.

There's probably truth in both statements tbh

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

No branches or pull requests