execution fails MODULE_NOT_FOUND
- Vorherrschende Sprache
- TypeScript
- Sterne
- 11.2k
- Forks
- 325
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne bei index.js Zeile 3 und vergleiche dessen require-Pfad mit dem main-Feld von package.json, wobei du das gemeldete Layout von node_modules/.bin im Cache als Kontext verwendest. Erledigt ist dies, wenn patch-package dist/index.js korrekt auflöst und der CI-Aufruf nicht mehr MODULE_NOT_FOUND auslöst.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100