Skip to content
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

fix(docs): clarify what install type gets .bins #3491

Merged
merged 1 commit into from Jul 1, 2021

Conversation

wraithgar
Copy link
Member

"on install" was ambiguous because it wasn't clear if it meant "when npm
install is ran on this project" or "when this project is installed
somewhere else"

References

Related to #3488

@wraithgar wraithgar requested a review from a team as a code owner July 1, 2021 15:20
@NfNitLoop
Copy link

TBH, even knowing the distinction you’re trying to make from comments you left in #3488 this change wouldn’t make that clear to me.

@NfNitLoop
Copy link

“On install” vs “when this package is installed” read the same to me, as someone just trying to npm install a package.

is that wording meaningful to more experienced npm devs?

@wraithgar
Copy link
Member Author

wraithgar commented Jul 1, 2021

npm install installs the dependencies of a given module
npm install x installs the package x into a given module, this is what is meant by "installing a package"

The fact that some people have a mental model of "running npm install" means "installing a package" instead of "installing the dependencies for a package" is probably larger than this PR can address. They are definitely not the same thing.

What wording would you recommend then?

@NfNitLoop
Copy link

I’m not at a computer at the moment. But distinguishing those two cases by path might be more clear.

roughly:

When installing to $globalDir, this script’s bin gets installed. When installing to node_modules/.bin, this script’s dependencies’ “bin” get installed.

(and maybe also a note about the thing you mentioned — that it’s not recommended to directly use nod_modules/.bin scripts directly.)

@wraithgar
Copy link
Member Author

wraithgar commented Jul 1, 2021

I think mentioning the .bin at all is a mistake. Gonna tweak the copy here to remove that and make it clear what the differences are, and the way to invoke those bins.

To use this, supply a `bin` field in your package.json which is a map of
command name to local file name. When this packaged is installed, npm
will symlink that file into a place where it can be invoked by name if
installed globally, or by `npm exec` when installed in another package.

@wraithgar
Copy link
Member Author

Ok that's done. Thanks for helping make sure the docs make sense to you.

installs.
command name to local file name. When this packaged is installed, npm
will symlink that file into a place where it can be invoked by name if
installed globally, or by `npm exec` when installed in another package.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
installed globally, or by `npm exec` when installed in another package.
installed globally, or by `npm exec` or `npm run-script` when installed in another package.

“when installed globally” is only true when the PATH contains the global npm bin location; should that be called out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "source" of truth for executables is at https://docs.npmjs.com/cli/v7/configuring-npm/folders#executables so we should link there instead of trying to re-describe it.

Documenting "{prefix}/bin needs to be in your PATH" should probably be in the configuring section.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually run-script is incorrect. That only works for scripts entries, not bin. Removing that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run-script entries in "another package" definitely has access to the bin tho; that's what i was trying to convey.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, you can't npm run-script that package by name but you can refer to it by name in things run via npm run-script. I hope the new copy reflects this better.

@wraithgar
Copy link
Member Author

Copy has been updated to clarify even more how the bins are intended to be used locally or globally, and a note on adding your global bin to PATH was added to the appropriate section in `folders

@wraithgar
Copy link
Member Author

Thanks @ljharb. We were too late for today's release so this'll go out in two weeks.

"on install" was ambiguous because it wasn't clear if it meant "when npm
install is ran on this project" or "when this project is installed
somewhere else"

PR-URL: #3491
Credit: @wraithgar
Close: #3491
Reviewed-by: @ljharb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants