yarn
yarn copied to clipboard
`yarn unlink package` doesn't restore node_modules/package
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.
Seem to be the same issue https://github.com/yarnpkg/yarn/issues/937
+1, same issue here!
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.
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)
unlink should reinstall.
it works with a force install, but it surprises me why it doesn't with a normal yarn install
using 1.2.1
Running yarn install --check-files seems to restore the package in v1.4.0.
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.
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).
I just switched my terminal to Windows PowerShell and all works)
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