Yarn: `yarn install` doesn't install if node_modules is present but in the wrong state

Created on 21 Apr 2017  ยท  4Comments  ยท  Source: yarnpkg/yarn

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.

  • Node: 6.9.1
  • Yarn: 0.23.2
  • OS: OS X 10.11.6

Most helpful comment

Currently this is the expected behavior. If you want to check every time you can run yarn install --check-files

All 4 comments

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?

Was this page helpful?
0 / 5 - 0 ratings