install-peerdeps icon indicating copy to clipboard operation
install-peerdeps copied to clipboard

Cannot read property 'forEach' of undefined

Open mojo2012 opened this issue 3 years ago • 8 comments

Running something like install-peerdeps -d postcss@^8.1.0 just gives me this output:

install-peerdeps v3.0.3
ERR Cannot read property 'forEach' of undefined

mojo2012 avatar Apr 12 '21 06:04 mojo2012

Can you share your operating system and Node/NPM version (node -v, npm -v)?

nathanhleung avatar Apr 12 '21 18:04 nathanhleung

macOS: 11.2.3 (20D91) Node: v14.16.0 npm: 6.14.11

mojo2012 avatar Apr 13 '21 06:04 mojo2012

It appears that PostCSS ^8.1.0 doesn't have any peer dependencies: https://github.com/postcss/postcss/blob/8.1.14/package.json, so I think the error is being thrown because the peer dependency array is undefined.

The error message needs to be better, so will keep this open.

nathanhleung avatar Apr 13 '21 13:04 nathanhleung

Does there need to be an error in that case? If there’s no peer deps, then this module can nearly install the package requested and it’s done.

ljharb avatar Apr 13 '21 13:04 ljharb

Does there need to be an error in that case? If there’s no peer deps, then this module can nearly install the package requested and it’s done.

That's a good point -- maybe just a warning/info message since I'm guessing users who use install-peerdeps are generally intending/expecting extra peer deps to be installed?

nathanhleung avatar Apr 13 '21 14:04 nathanhleung

That seems reasonable.

ljharb avatar Apr 13 '21 14:04 ljharb

install-peerdeps version: 3.0.3

mojo2012 avatar Apr 14 '21 06:04 mojo2012

so... is this ever happening? the error is still there. sorry for a bit of necro, but it's kinda necessary

TobiTenno avatar Feb 13 '24 02:02 TobiTenno