yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

Yarn 1.0.1 workspaces does not work with scoped packages #4354

Open screendriver opened 7 years ago

screendriver commented 7 years ago

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 commented 7 years ago

Same issue here. This worked in 0.28.4

terrymunro commented 7 years ago

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 commented 7 years ago

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

screendriver commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

usulpro commented 7 years ago

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 commented 7 years ago

solved by specifying the package version:

-"@storybook/cdk-scripts": "*"
+"@storybook/cdk-scripts": "^0.1.1-alpha"
joefiorini commented 7 years ago

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 commented 7 years ago

I can still reproduce this with yarn@1.3.2. I have:

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

egeriis commented 6 years ago

This is still an issue in yarn@1.5.1

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

rally25rs commented 6 years ago

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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

wtf

jkhaui commented 3 years ago

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