ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.26k stars 287 forks source link

"ENOENT: no such file or directory, stat" when patching module with file that symlinks within package #445

Open garrettg123 opened 1 year ago

garrettg123 commented 1 year ago
patch-package 6.5.0
• Creating temporary folder
• Installing @sentry/react-native@4.9.0 with yarn
• Diffing your files with clean files
Error: ENOENT: no such file or directory, stat '/Users/me/Sites/project/node_modules/@sentry/react-native/node_modules/@sentry/cli/node_modules/.bin/mkdirp'
    at Object.statSync (node:fs:1583:3)
    at Object.statSync (/Users/me/Sites/project/node_modules/graceful-fs/polyfills.js:319:16)
    at checkStats (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:171:22)
    at checkPaths (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:183:31)
    at copyDirItem (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:117:20)
    at /Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:39
    at Array.forEach (<anonymous>)
    at copyDir (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:23)
    at mkDirAndCopy (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:106:3)
    at onDir (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:97:37) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/Users/me/Sites/project/node_modules/@sentry/react-native/node_modules/@sentry/cli/node_modules/.bin/mkdirp'
}
/Users/me/Sites/project/node_modules/patch-package/dist/makePatch.js:218
        throw e;
        ^

Error: ENOENT: no such file or directory, stat '/Users/me/Sites/project/node_modules/@sentry/react-native/node_modules/@sentry/cli/node_modules/.bin/mkdirp'
    at Object.statSync (node:fs:1583:3)
    at Object.statSync (/Users/me/Sites/project/node_modules/graceful-fs/polyfills.js:319:16)
    at checkStats (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:171:22)
    at checkPaths (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:183:31)
    at copyDirItem (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:117:20)
    at /Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:39
    at Array.forEach (<anonymous>)
    at copyDir (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:23)
    at mkDirAndCopy (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:106:3)
    at onDir (/Users/me/Sites/project/node_modules/patch-package/node_modules/fs-extra/lib/copy-sync/copy-sync.js:97:37) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/Users/me/Sites/project/node_modules/@sentry/react-native/node_modules/@sentry/cli/node_modules/.bin/mkdirp'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The file that can't be found is a symlink to ../../../../mkdirp/bin/cmd.js.

ramblingenzyme commented 1 year ago

Also ran into this with the latest version and trying to patch next. I don't know exactly which version introduced this, but I jumped all the way back to v6.0.0 to fix it.