Cli: [FEATURE] Document the peerDependenciesMeta in the package.json

Created on 5 May 2020  路  7Comments  路  Source: npm/cli

I cant find info about the peerDependenciesMeta field in the package.json:

https://docs.npmjs.com/files/package.json

References

It was mentioned at the npm blog here:

https://blog.npmjs.org/post/186983646370/npm-cli-roadmap-summer-2019

New features likely to land on the 6.x branch:

Add support for the peerDependenciesMeta field. (#224)

Also here in the changelog:

https://github.com/npm/cli/releases/tag/v6.11.0

Also the release announcement:

https://npm.community/t/release-6-11-0/9572

Enhancement

Most helpful comment

@abdonrd there is a PR here that is not yet merged: https://github.com/npm/cli/pull/1822

All 7 comments

Any news? Thanks in advance!

Formal documentation on this feature would be great. I know npm 7+ is going back to the behavior of installing peerDependencies for you if they are not already in your package.json. Now I'm left wondering how that works when a peer dependency is marked as optional in peerDependenciesMeta.

Edit: I've confirmed locally that peerDependencies marked as optional using peerDependenciesMeta are auto-installed.
I've opened this issue at npm/rfcs: https://github.com/npm/rfcs/issues/221

Any news?

@abdonrd there is a PR here that is not yet merged: https://github.com/npm/cli/pull/1822

Is peerDependenciesMeta deprecated in favour of optionalDependencies?

@wheresrhys they're entirely different, albeit similar. optionalDependencies means, if the dep fails to install, don't fail the overarching install. peerDependenciesMeta allows you to provide extra information about peer deps, and marking one "optional" means "it's not an error if it's missing".

Thanks. I had to read that through a few times to grasp it, but I think I've got it now.

This distinction really needs documenting properly. I've just had a PR submitted https://github.com/wheresrhys/fetch-mock-jest/pull/22 where the submitter almost certainly wants peerDependenciesMeta but has used optionalDependencies.

I'd be happy to help, but maybe best as a non-expert reviewer as I don't think I have the familiarity needed to actually write the docs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DullReferenceException picture DullReferenceException  路  4Comments

zypA13510 picture zypA13510  路  4Comments

darcyclarke picture darcyclarke  路  3Comments

darcyclarke picture darcyclarke  路  4Comments

dr-js picture dr-js  路  3Comments