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

Does Yalc resolve dependencies as if I npm installed the local module? #50

Open
naddison opened this issue Dec 2, 2018 · 10 comments
Open

Comments

@naddison
Copy link

naddison commented Dec 2, 2018

Let's say I have two packages A and B. B depends on A. I use yalc to add A to B, will yalc resolve A's dependencies into B's node_modules folder (as if I npm installed A)?

@wclr
Copy link
Owner

wclr commented Dec 3, 2018

Let's say I have two packages A and B. B depends on A. I use yalc to add A to B, will yalc resolve A's dependencies into B's node_modules folder (as if I npm installed A)?

You mean after you installed then B somewhere? if your B package will contain .yalc/A folder inside then yes.

@aleclarson
Copy link
Contributor

aleclarson commented Jan 2, 2019

This question may have been misread. From a look at the code, it seems that the dependencies of package "A" are not resolvable when a consuming package "B" uses yalc link.

For example, if both of these are true:

  • package "A" depends on package "C" (via npm install)
  • package "B" depends on package "A" (via yalc link)

..then this is also true:

  • package "C" is missing from $B/.yalc/$A/node_modules

@aleclarson
Copy link
Contributor

I assume the intention was for users to run yarn (or similar) after yalc link to ensure the dependencies are installed. Maybe there's a good argument for copying node_modules into .yalc/{name}/node_modules during yalc link?

@aleclarson
Copy link
Contributor

The following should be added to the docs:

If your project is not using Yarn, you must run npm install (or similar) after yalc add in order to install the added package's dependencies.

Then, we should change yalc link to run npm install (or yarn if --yarn was used) inside the .yalc/{name} directory. I was considering just copying node_modules during yalc publish, but I decided it's better to mimic a "normal install" as much as possible.

I'll be working on a PR sometime soon, so LMK what you think @whitecolor.

@aleclarson
Copy link
Contributor

Hmm, actually, it might be best to run npm install (or yarn if yarn.lock exists) in ~/.yalc during yalc publish or yalc push.

PS: I'm curious, why does yalc add need to copy the .yalc/{name} directory into node_modules? Why not use a symlink like yalc link does? Then, the only difference between add and link would be that add mutates the package.json of the consuming package.

aleclarson added a commit to aleclarson/yalc that referenced this issue Jan 2, 2019
aleclarson added a commit to aleclarson/yalc that referenced this issue Jan 2, 2019
aleclarson added a commit to aleclarson/yalc that referenced this issue Jan 11, 2019
@luk707
Copy link

luk707 commented Apr 18, 2019

@aleclarson

I assume the intention was for users to run yarn (or similar) after yalc link to ensure the dependencies are installed. Maybe there's a good argument for copying node_modules into .yalc/{name}/node_modules during yalc link?

I agree, this is the workflow I ended up using. I'm not a fan of installing the node_modules into the yalc directory though. The main reason I started using yalc is to solve an issue where I'd have duplicate versions of React in my node_modules in my linked environment but not my production environment. I've proposed instead that it runt's yarn link or npm install in my issue: #81.

@eric-burel
Copy link

eric-burel commented May 7, 2021

I am hitting this issue with Next.js + Storybook, must admit it's confusing at first. I'd rather had yalc behaving exactly like an NPM registry, but local. The problem is that when I run the npm install, it also kinda defeats the purpose of Yalc.
For a precise example, Next.js will use Webpack 4 internally. But some app may use Webpack 5. If I don't do the npm install, just yalc link, it will use my app Webpack 5 install as expected (this is why I am using Yalc in the first place, Yarn link won't allow that). But I have missing packages then. If I do the npm install, back to square one....

(non minimal) reproduction here: https://github.com/lbke/next-plugin-storybook-demo, if you don't npm install you have errors with either chalk or jest-worker, because it is not installed in the linked next.js deps.

I am not knowledgeable enough to fully grasp what happens, but it doesn't seem to behave like an npm install would do.

Note I am using yarn, and yalc link (but not yalc add I am not fond of the file:https:// dependency)

@danny-does-stuff
Copy link

Was this issue ever resolved? I'm having a very similar issue. When I run yalc link A in package B, I don't see C appear anywhere. Not in B/node_modules, not in B/.yalc/A, and not in ~/.yalc/packages/A. At that point I run yarn install and nothing happens, it just says "Already up-to-date". Regardless of the ultimate resolution of this issue, I would love to understand better how this is working so I can at least get it working. Thank you for your help and this great package!

@IhebMarnaoui
Copy link

Im having the same issue as described above, can this get a higher priority ?

@ivan-kleshnin
Copy link

ivan-kleshnin commented Aug 29, 2024

can this get a higher priority ?

I wouldn't bet on that. Repository Last updated: 2 years ago...
My advice: use Bun.

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

8 participants