Uh oh!
There was an error while loading. Please reload this page.
docs: clarify what peerDependenciesMeta does - #7433
Conversation
wraithgar
commented
May 1, 2024
The whole section needs to be removed if it does not apply to the currently supported version of npm. We don't need to document old unsupported versions. |
xuhdev
commented
May 1, 2024
@wraithgar Got it, I've updated the PR. peerDependenciesMeta is still used by the latest npm, but the current doc seems to have missed the most important points while talks a lot about the behavior of old npm versions. |
| dependencies to be marked as optional. Npm would not automatically install | ||
| optional peer dependencies. This allows you to |
There was a problem hiding this comment.
Npm would not automatically install optional peer dependencies.
This is a very confusing and potentially misleading sentence. At a glance it reads that npm does not install optional peer dependencies. In fact it does, it just does not raise an error if they can not be installed.
There was a problem hiding this comment.
I tried this myself, npm seems to not install optional peer dependencies by default. I"m on npm version 10.7.0.
mkdir my-package && cd my-package- Save the following file to
package.json:
{
"name": "tea-latte",
"version": "1.3.5",
"peerDependencies": {
"lodash": "4.17.21",
"core-js": "3.37.0"
},
"peerDependenciesMeta": {
"lodash": {
"optional": true
}
}
}npm install.
Observe that node_module doesn't contain lodash, but it contains core-js.
Then:
npm pack(which generatestea-latte-1.3.5.tgz)mkdir ../user && cd ../usernpm install ../my-package/tea-latte-1.3.5.tgz
Same effect, only core-js is installed, not lodash.
There was a problem hiding this comment.
Well then my memory of the situation was wrong. I must have gotten optional and optional peer dependencies confused. Thanks.
Uh oh!
There was an error while loading. Please reload this page.
wraithgar
commented
May 1, 2024
Small grammar suggestion and we can land this. |
No description provided.