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 unlink package doesn't restore node_modules/package #1957

Open
wclr opened this issue Nov 20, 2016 · 11 comments
Open

yarn unlink package doesn't restore node_modules/package #1957

wclr opened this issue Nov 20, 2016 · 11 comments

Comments

@wclr
Copy link
Contributor

wclr commented Nov 20, 2016

After yarn link package yarn creates symlink node_module/package, but after yarn unlink package it just removes node_module/package and not places there hard installed version.

Probably expected that it should find in cache or fetch a correct version from registry and replace removed symlink with it.

@wclr
Copy link
Contributor Author

wclr commented Nov 20, 2016

Seem to be the same issue #937

@caesarsol
Copy link

+1, same issue here!

@andybluntish
Copy link

From the docs (https://yarnpkg.com/en/docs/cli/unlink#toc-yarn-unlink-package) this seems to be expected behaviour. However, as noted in #937 running yarn does not add the package back to node_modules.

@caesarsol
Copy link

Yes, it seems yarn check detects the package is missing, but yarn install does not restore it...

I have to run yarn install --force to make it right.

(As a possible improvement, I think unlink could reinstall the original package by itself)

@wclr
Copy link
Contributor Author

wclr commented Mar 22, 2017

unlink should reinstall.

@danielepiccone
Copy link

danielepiccone commented Feb 16, 2018

it works with a force install, but it surprises me why it doesn't with a normal yarn install
using 1.2.1

@stephencroberts
Copy link

Running yarn install --check-files seems to restore the package in v1.4.0.

@remino
Copy link

remino commented Dec 26, 2018

This has been going on since 2016? I'm having the same issue with yarn 1.12.3.

If a yarn install --check-files or a yarn install --force is required, we should at least being told so in the note after yarn unlink instead of saying we only need to do a normal yarn install.

@arcanis
Copy link
Member

arcanis commented Jan 23, 2019

I don't think yarn unlink package is meant to trigger an install (or at least, I'd feel uncomfortable changing this behavior anywhere else than in a major release). In the case where multiple packages are linked / unlinked (mostly scripts), running an new install every time would cause a perf hit.

That said, yarn install not noticing that a link disappeared is a bug. I don't have time right now to work on this, but #6931 seems an acceptable workaround for the time being (except that I'd recommend to use --force rather than --check-files, since the later has long-term effects).

@MykhailoTurokCoax
Copy link

I just switched my terminal to Windows PowerShell and all works)

@dalmo3
Copy link

dalmo3 commented Jun 11, 2022

None of the suggestions above work for yarn v2 or v3 - most of those flags don't even exist. The only option is the going nuclear:

rm -rf node_modules 
yarn

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