I have a monorepo with a build script that calls fs.cpSync to copy Yarn-installed dependencies into a build directory. When using Yarn and Node 20, it works fine. When using Yarn and Node 22, it fails with
Copying /private/tmp/test/.yarn/cache/semver-npm-7.6.3-57e82c14d5-88f33e148b.zip/node_modules/semver/package.json to semver.json...
node:internal/fs/cp/cp-sync:56
fsBinding.cpSyncCheckPaths(src, dest, opts.dereference, opts.recursive);
^
Error: Unknown system error 17: Unknown system error 17, lstat '/private/tmp/test/.yarn/cache/semver-npm-7.6.3-57e82c14d5-88f33e148b.zip/node_modules/semver/package.json'
at cpSyncFn (node:internal/fs/cp/cp-sync:56:13)
at Object.cpSync (node:fs:3044:3)
at Object.<anonymous> (/private/tmp/test/packages/foo/index.cjs:7:4)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at require$$0.Module._extensions..js (/private/tmp/test/.pnp.cjs:5699:33)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at require$$0.Module._load (/private/tmp/test/.pnp.cjs:5547:31)
at TracingChannel.traceSync (node:diagnostics_channel:315:14) {
errno: 17,
code: 'Unknown system error 17',
syscall: 'lstat',
path: '/private/tmp/test/.yarn/cache/semver-npm-7.6.3-57e82c14d5-88f33e148b.zip/node_modules/semver/package.json'
}
Node.js v22.6.0
To reproduce
You can use the following script to reproduce. For example,
Self-service
Describe the bug
I have a monorepo with a build script that calls
fs.cpSync
to copy Yarn-installed dependencies into a build directory. When using Yarn and Node 20, it works fine. When using Yarn and Node 22, it fails withTo reproduce
You can use the following script to reproduce. For example,
should succeed, while
should fail. Here is the script,
repro.sh
:Environment
Additional context
No response