question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating patch file for GitHub dependency fails with ENOENT: no such file or directory

See original GitHub issue

I was trying to create a patch for a GitHub dependency I added to my projects like this in package.json: "react-native-scrollable-tab-view": "git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"

And creating the patch fails with:

• Diffing your files with clean files Error: ENOENT: no such file or directory, scandir ‘/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view’ at Object.readdirSync (node:fs:1067:3) at Object.klawSync [as default] (/…/react-native/node_modules/klaw-sync/klaw-sync.js:13:25) at Object.removeIgnoredFiles (/…/react-native/node_modules/patch-package/dist/filterFiles.js:10:24) at Object.makePatch (/…/react-native/node_modules/patch-package/dist/makePatch.js:123:23) at /…/react-native/node_modules/patch-package/dist/index.js:48:25 at Array.forEach (<anonymous>) at Object.<anonymous> (/…/react-native/node_modules/patch-package/dist/index.js:47:22) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions…js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) { errno: -2, syscall: ‘scandir’, code: ‘ENOENT’, path: ‘/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view’ } /…/react-native/node_modules/patch-package/dist/makePatch.js:184 throw e; ^

Error: ENOENT: no such file or directory, scandir ‘/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view’ at Object.readdirSync (node:fs:1067:3) at Object.klawSync [as default] (/…/react-native/node_modules/klaw-sync/klaw-sync.js:13:25) at Object.removeIgnoredFiles (/…/react-native/node_modules/patch-package/dist/filterFiles.js:10:24) at Object.makePatch (/…/react-native/node_modules/patch-package/dist/makePatch.js:123:23) at /…/react-native/node_modules/patch-package/dist/index.js:48:25 at Array.forEach (<anonymous>) at Object.<anonymous> (/…/react-native/node_modules/patch-package/dist/index.js:47:22) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions…js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) { errno: -2, syscall: ‘scandir’, code: ‘ENOENT’, path: ‘/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view’ }

I then looked a bit into makePatch.js and found the automatically created package.json looking like this: {"dependencies":{"react-native-scrollable-tab-view":"react-native-scrollable-tab-view@git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"},"resolutions":{}}

So just to check if the react-native-scrollable-tab-view@ is the issue I replaced the getPackageResolution call in makePatch.js:49 with the static GitHub URL I used in the package.json above and the patch file was created correctly: {"dependencies":{"react-native-scrollable-tab-view":"git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"},"resolutions":{}}

I am now wondering if I am linking the GitHub dependency in a wrong way (though I tried various other) or if this is a bug or not expected usage of patch-package at all.

All of this happened on macOS 11.1 with patch-package 6.2.2.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

10reactions
cestefcommented, Jun 27, 2021

replace makePatch:50 with the following: fs_extra_1.writeFileSync(tmpRepoPackageJsonPath, JSON.stringify({ dependencies: { [packageDetails.name]: getPackageResolution_1.getPackageResolution({ packageDetails, packageManager, appPath, }).replace(/(.*)@/g, ""), }, resolutions: resolveRelativeFileDependencies_1.resolveRelativeFileDependencies(appPath, appPackageJson.resolutions || {}), }));

it’s quite a messy solution, but it still works for me 😂

3reactions
cestefcommented, Jul 17, 2021

@cstefFlexin I’m not really sure what your “fix” is meant todo there as the returned URL is incorrect.

https://github.com/ds300/patch-package/issues/335 fixes the issue.

I am just replacing the first part of the git url, it seemed to work, but your solution looks cleaner indeed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating patch file for GitHub dependency fails with ENOENT
Creating patch file for GitHub dependency fails with ENOENT: no such file or directory.
Read more >
ENOENT: no such file or directory when running npm install ...
Check the node version, if the application was build using an older node version then you can downgrade your local environment ...
Read more >
How to fix: npm ERR! enoent ENOENT: no such file or ...
delete node-modules folder · run command npm cache clean --force · run command npm install · install the package again with npm install...
Read more >
patch-package - npm
fix a bug in one of your dependencies vim node_modules/some-package/brokenFile.js # run patch-package to create a .patch file npx ...
Read more >
NPM | Josh Buchea
[any] (latest patch). Error: "ENOENT: no such file or directory, uv_cwd". Weird shell/dir issue, restart shell(s); https://github.com/nodejs/node/issues/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found