Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Removing packages that are listed in yarn.lock from node_modules without removing node_modules itself then running yarn install does _not_ see Yarn reinstall the missing packages.
If the current behavior is a bug, please provide the steps to reproduce.
> mkdir test && cd test
> npm init --yes
<... snip ...>
> yarn add leftpad
yarn add v0.23.2
info No lockfile found.
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
โโ [email protected]
โจ Done in 0.61s.
> ls node_modules
leftpad
> cat yarn.lock
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
leftpad@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/leftpad/-/leftpad-0.0.0.tgz#020c9ad0787216ba0f30d79d479b4b355d7d39c3"
> rm -rf node_modules/leftpad
> yarn install
yarn install v0.23.2
[1/4] ๐ Resolving packages...
success Already up-to-date.
โจ Done in 0.17s.
> ls node_modules
> cat yarn.lock
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
leftpad@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/leftpad/-/leftpad-0.0.0.tgz#020c9ad0787216ba0f30d79d479b4b355d7d39c3"
> rm -rf node_modules
> yarn install
yarn install v0.23.2
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
โจ Done in 0.21s.
> ls node_modules
leftpad
> cat yarn.lock
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
leftpad@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/leftpad/-/leftpad-0.0.0.tgz#020c9ad0787216ba0f30d79d479b4b355d7d39c3"
What is the expected behavior?
In the above example, when node_modules is present but empty, leftpad should be installed to bring it up-to-date with the lockfile.
Please mention your node.js, yarn and operating system version.
Currently this is the expected behavior. If you want to check every time you can run yarn install --check-files
I just found https://github.com/yarnpkg/yarn/issues/2240 which appears to be a duplicate of this issue, so it looks like this is a point of confusion that has been around for quite some time.
@torifat awesome., is there a reason it's not promoted in the documentation?
@codebymikey https://github.com/yarnpkg/website/pull/497
Most helpful comment
Currently this is the expected behavior. If you want to check every time you can run
yarn install --check-files