patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

Cannot read property 'dependencies' of undefined

Open Dumbliidore opened this issue 3 years ago β€’ 8 comments

I use it in my project, then it made a mistake, the error message is shown in the figure below.

patch-package 6.2.2
β€’ Creating temporary folder
TypeError: Cannot read property 'dependencies' of undefined
    at Object.getPackageResolution (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\getPackageResolution.js:71:38)
    at Object.makePatch (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\makePatch.js:49:66)
    at D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\index.js:48:25
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\index.js:47:22)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\makePatch.js:183
        throw e;
        ^

TypeError: Cannot read property 'dependencies' of undefined
    at Object.getPackageResolution (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\getPackageResolution.js:71:38)
    at Object.makePatch (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\makePatch.js:49:66)
    at D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\index.js:48:25
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (D:\Dev\React\account-book\node_modules\[email protected]@patch-package\dist\index.js:47:22)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)

package.json

"devDependencies": {
    "concurrently": "^5.3.0",
    "json-server": "^0.16.2",
    "patch-package": "^6.2.2"
  }

Dumbliidore avatar Dec 04 '20 13:12 Dumbliidore

https://github.com/ds300/patch-package/issues/234

pavelustenko avatar Mar 30 '21 13:03 pavelustenko

@D-zilch this can happen if you have nothing for "dependencies" key in package.json. try making it blank: "dependencies": {}

chrismcleod avatar May 06 '21 19:05 chrismcleod

Face the same issue when trying to run in lerna monorepo

JasoonX avatar Nov 15 '21 17:11 JasoonX

This means it can not find the package in the package-lock.json file. In my case, I was using: npx patch-package History where I should have been using: npx patch-package history Yes, it is case sensitive. The error message could do with improving.

StephenHeise avatar Jun 12 '22 23:06 StephenHeise

I have a patch to improve the error message. No idea how to create a PR for it - currently I get a permission denied when I try to push my local branch. I'm a GitHub newbie and can't find anything about how contribute to this project. Any help?

StephenHeise avatar Jun 13 '22 00:06 StephenHeise

In my case, I had both package-lock.json and yarn.lock files. It turns out the package-lock.json has not been updated as I have been using yarn. I had to delete package-lock.json file.

odelolajosh avatar Aug 06 '22 14:08 odelolajosh

In my case, I had both package-lock.json and yarn.lock files. It turns out the package-lock.json has not been updated as I have been using yarn. I had to delete package-lock.json file.

ηœŸηš„ζ˜―ε€ͺζ„Ÿθ°’ζ‚¨δΊ†πŸ˜ƒ

57124 avatar Sep 26 '23 02:09 57124

I encountered the same issue. @ds300 image

blueMountain007 avatar Mar 15 '24 10:03 blueMountain007