yarn
yarn copied to clipboard
Error: ENOENT: no such file or directory, copyfile
Do you want to request a feature or report a bug? bug
What is the current behavior?
When having a yarn workspace, adding one of the packages to another and then executing yarn install
throws this error:
Error: ENOENT: no such file or directory, copyfile '/Users/tim/Library/Caches/Yarn/v1/npm-jsonfile-4.0.0-8771aae0799b64076b76640fca058f9c10e33ecb/CHANGELOG.md' -> '/Users/tim/code/prisma-deployment-test/cli/node_modules/prisma-yml/node_modules/jsonfile/CHANGELOG.md'
If the current behavior is a bug, please provide the steps to reproduce.
git clone [email protected]:graphcool/prisma.git
git checkout 97b85c6d7ac0f8eabbb481b4e9b81f99d67d8f99
cd cli/packages/prisma-yml
yarn install
yarn build
cd ../prisma-cli-engine/
yarn add -E prisma-yml
yarn install #BOOM
What is the expected behavior?
Execute yarn install
without throwing an error.
Please mention your node.js, yarn and operating system version.
[email protected]
[email protected]
macOS [email protected]
That's a strange one. Even after it errors, I can stat
both the "from" and "to" files reported in the error, and they both exist 😕
I was having a similar issue but worked around it by removing node_modules
. Guess that's not the most friendly solution here, though.
When I just tried to reproduce the bug, I got there error already during the "yarn add -E prisma-yml" step. The "no such file or directory" message was appropriate here since the target directory cli/node_modules/prisma-yml/node_modules/jsonfile
really didn't exist.
rm -rf node_modules && yarn cache clean && yarn install
solves most such problems.
For what it's worth, I wasn't able to cure with the steps Markus suggests. I even tried reinstalling yarn and manually deleting the yarn cache using rm -fr ~/Library/Caches/Yarn
.
I did find a partial solution. I'm posting here in hopes it sheds light on what the underlying issue might be. Bullet 4 below shows how I fixed it.
My situation:
- The file causing the ENOENT error is a dependency of a private module I added using
yarn add ssh+git://[email protected]/me/myprivatemodule.git
. To be specific,myprivatemodule
depends onmathjs
, andyarn install
was stopping with:
error An unexpected error occurred: "https://registry.yarnpkg.com/mathjs/-/mathjs-5.0.2.tgz: ENOENT: no such file or directory, open '/Users/aneil/Library/Caches/Yarn/v1/npm-mathjs-5.0.2-ed23dcfb40e886697447bcfe43e5dc5d92dd8eb0/docs/reference/functions/permutations.md'".
- Looking in the Yarn cache, I noticed (after attempting to install with a clean cache) that I had two copies of mathjs:
npm-mathjs-3.20.2-3218aebde7de8cb5627c8fe3a1a216bf399ba91d/
npm-mathjs-5.0.2-ed23dcfb40e886697447bcfe43e5dc5d92dd8eb0/
And... the 5.0.2 directory was empty, which is why I was seeing the error.
-
It's worth noting that I was attempting to
yarn install
a freshly cloned repo on a new machine -
Running
yarn add ssh+git://[email protected]/me/myprivatemodule.git
fixed the problem -
I can reproduce the error with
rm -fr node_modules && yarn cache clean && yarn install
So, although I can continue development, I suspect my CI is borked.
Update:
I see why I have two copies of the offending module - another dependency of my private module depends on the 3.20.2 version of mathjs. However, making myprivatemodule
use the same version of mathjs doesn't solve the issue.
I had this today, and had to rm -rf
my yarn cache dir, the one used when running yarn
in ~/.cache/yarn
and the one in /usr/local/share/.cache/yarn
used when running sudo yarn
. This is in Ubuntu 18 on Windows 10.
❯ node -v
v10.15.0
❯ npm -v
6.6.0
❯ yarn -v
1.13.0
This is still an issue, even in 1.14
Arguments:
/home/jeff/n/bin/node /usr/share/yarn/bin/yarn.js install
PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/jkono/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jkono/AppData/Local/hyper/app-2.1.2/resources/bin:/mnt/c/Users/jkono/AppData/Local/Programs/Microsoft VS Code/bin:/home/jeff/n/bin
Yarn version:
1.14.0
Node version:
10.15.1
Platform:
linux x64
Trace:
Error: ENOENT: no such file or directory, scandir '/mnt/c/Users/jkono/dev/PROJECT/node_modules/@storybook/addon-links/src'
still errs after rm -rf node_modules
and yarn cache clean
.
Yarn version: 1.13.0
Node version: 11.10.0
Platform: linux x64 (WSL)
Trace: Error: ENOENT: no such file or directory, lstat '/home/h/.cache/yarn/v4/npm-enhanced-resolve-4.1.0-41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f/node_modules/enhanced-resolve/lib/AliasPlugin.js'
fix with yarn global add yarn
to re-install yarn. (someone tells me what happens?)
I found success by reinstalling yarn w/brew.
Had the same problem upgrading to yarn 1.15.2. removing node modules and cleaning cache did the trick.
still errs after
rm -rf node_modules
andyarn cache clean
.Yarn version: 1.13.0
Node version: 11.10.0
Platform: linux x64 (WSL)
Trace: Error: ENOENT: no such file or directory, lstat '/home/h/.cache/yarn/v4/npm-enhanced-resolve-4.1.0-41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f/node_modules/enhanced-resolve/lib/AliasPlugin.js'
fix with
yarn global add yarn
to re-install yarn. (someone tells me what happens?)
This worked for me
For those hitting this problem from inside WSL on Windows, this fixed it for me:
- Delete
node_modules
- Install/update yarn on host Windows installation
- Run
yarn install
inside the project from within Windows cmd/powershell
Installation succeeded, and switching back to an Ubuntu terminal (in WSL (inside VSCode)) I could yarn start
without issue.
This may not have anything to do with the issue here, but in case it helps, I have run across this issue when trying to copy files in between different volumes (especially NAS volumes) using the native fs routines.
I have this message from type to time when using Yalc to symlink folders
I got the same problem. It started occurring in my CI after refactoring a lot of files WITHOUT doing any changes to the package.json
or yarn.lock
file. The refactor did however change in what order the dependencies were called.
I'm unfortunately not able to share the repository since it is a private work repository. . However, I was able to solve it by having the CI run yarn install --network-concurrency 1 --frozen-lockfile
instead of yarn install --frozen-lockfile
.
It looks like this is still a problem with --network-concurrency 1
😕 Setting that just seems to reduce how frequently it occurs.
yea ive been seeing this issue a lot lately
version problem ?
Started with:
npm install --global yarn
yarn cache clean
DEL /F/Q/S node_modules > NUL 2>&1 & RMDIR /S/Q node_modules > NUL 2>&1
Added below to User Environment variables
%LocalAppData%\Yarn\bin
Then
yarn install
Then since the issue was eslint
in my case, did below
yarn global add eslint
yarn add eslint -D
Then did:
npm install --global eslint
npm install -D eslint
Then in VS Code, output, in dropdown, I saw error in linter
:
So uninstalled below:
marketplace.visualstudio.com/items?itemName=fnando.linter
Then it worked, this was unexpected!
rm -rf node_modules && yarn cache clean && yarn install
solves most such problems.
I've tried the suggestion above and worked here
Update:
I think in my case it happened because the project was initially installed with pnpm, and I ran yarn add
thereafter.
Hitting this error consistently today.
Both locally on MacOS and on Ubuntu in CI: https://github.com/akd-io/create-next-stack/actions/runs/4772052085/jobs/8484361470?pr=172
local yarn-error.log:
Arguments:
/Users/akd/.nvm/versions/node/v18.13.0/bin/node /Users/akd/.nvm/versions/node/v18.13.0/bin/yarn add @emotion/react@^11.0.0 @emotion/styled@^11.0.0 @chakra-ui/icons@^2.0.0 @chakra-ui/react@^2.0.0 @mui/material@^5.0.0 react-hook-form@^7.0.0 formik@^2.0.0 framer-motion@^9.0.0 mrm@^4.0.0 mrm-task-lint-staged@^7.0.0
PATH:
/Users/akd/workspace/create-next-stack/packages/create-next-stack/node_modules/.bin:/Users/akd/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/pnpm/dist/node-gyp-bin:/Users/akd/workspace/create-next-stack/node_modules/.bin:/Users/akd/Library/pnpm:/opt/homebrew/opt/openjdk/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/akd/Library/pnpm:/opt/homebrew/opt/openjdk/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/akd/.yarn/bin:/Users/akd/.yarn/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin
Yarn version:
1.22.19
Node version:
18.13.0
Platform:
darwin arm64
Trace:
Error: ENOENT: no such file or directory, copyfile '/Users/akd/Library/Caches/Yarn/v6/npm-globby-11.1.0-bd4be98bb042f83d796f7e3811991fbe82a0d34b-integrity/node_modules/globby/index.js' -> '/Users/akd/workspace/create-next-stack-tests/run-d4eb6dcc-9846-4222-a5ef-100d98053b1e/node_modules/@typescript-eslint/typescript-estree/node_modules/globby/index.js'
npm manifest:
{
"name": "run-d4eb6dcc-9846-4222-a5ef-100d98053b1e",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "18.15.13",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"eslint": "8.39.0",
"eslint-config-next": "13.3.1",
"next": "13.3.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
}
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Solved this same issue by changing the Docker volume flags from delegated
to cached
; It seems like there were eventual consistency issues, and files weren't where they were expected in a timely fashion.
I hope this helps somebody!
My solution was removing the file mentioned on the error after the word copyfile
TL;DR
If all the previous solutions did not work with You, try this:
- Run:
yarn config set "strict-ssl" false -g
- Try again the installation