execution fails MODULE_NOT_FOUND
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
Hey ds300,
I am getting the following issue in CI
```
$ patch-package
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module './dist/index.js'
Require stack:
- /home/node_modules/.bin/patch-package
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
...
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/node_modules/.bin/patch-package' ]
```
I think the root cause stems from cachings the dependencies. The actual cause I assume is that the symlink in the `node_modules/.bin` is no longer a symlink and that the relative import from it therefore can no longer work.
As I have not encountered this issue with other cached packages I had a look into several of their `.bin` linked files and have seen that relative links are usually not used.
**I think this could be easily solved by changing the `require` here: https://github.com/ds300/patch-package/blob/master/index.js#L3 to `require("patch-package")`.**
This will correctly link to the same file as per the `package.json` `main` field.
Do you think that makes sense? Would you accept an PR for this or make the change yourself?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.