-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: clarify what peerDependenciesMeta does #7433
Conversation
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. |
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ../user
npm 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well then my memory of the situation was wrong. I must have gotten optional and optional peer dependencies confused. Thanks.
Small grammar suggestion and we can land this. |
No description provided.