ds300 / ds300/patch-package

execution fails MODULE_NOT_FOUND

Open
#246 2 comments 3 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.