Search code examples
javascriptyarnpkg

Yarn install: "Not a git repository" error when fetching packages


System: Windows 10 64 bit

I am trying to build a JavaScript project using yarn install --lock-file in the repository directory. When yarn tries to fetch the packages, it fails with the following error message:

Exit code: 128 Command: git Arguments: pull Directory: C:\Users\[UserDirectory]\AppData\Local\Yarn\Cache\v2.tmp\9f5ed3b3940e461693021bf6d9a7805d Output: fatal: not a git repository (or any of the parent directories): .git

I cannot figure out why yarn is trying to use git pull in another directory. Can you explain me what yarn is doing here?

Edit: At first, I guessed it must be an issue with access rights, but running it with elevated access gave the same result. The same goes for yarn install, so without the --frozen-lockfile flag.


Solution

  • I was getting the same error in a repo of mine too for any Yarn command.

    Removing the Yarn Cache fixed Yarn for me: yarn cache clean (recommended) or

    rm -rf C:\Users\<user>\AppData\Local\Yarn\Cache\v2.tmp\<hash> # the older hacky way