NPM metadata endpoint doesn't return the "bin" section
Summary
The npm Registry doesn't return the keys "bin"
The "bin" key is used to declare any executable provided the package. When $ npm
installs a package with such executables, depending on the conditions (global install), those executables will be linked in /usr/local/bin
. See https://docs.npmjs.com/cli/v6/configuring-npm/package-json#bin
Steps to reproduce
- publish an npm package to the npm Registry
-
$ npm view *package@version*
-> The bin is not listed
Example Project
-
https://gitlab.com/10io/npm-bin-demo
- Dummy bin project I fetched from Internet. The license is not clear so that project is private. Ping me for an access.
What is the current bug behavior?
Here is the output of $ npm view X
when the package is on GitLab:
@10io/X@1.2.3 | Proprietary | deps: 1 | versions: 1
dist
.tarball: link_to_tarball
.shasum: ce159462c166851c80e66168da61bbb11fa70c78
dependencies:
figlet-cli: ^0.1.0
dist-tags:
latest: 1.2.3
What is the expected correct behavior?
Here is the output of the same command when the package is on npmjs.org:
@10io/X@1.2.3 | Proprietary | deps: 1 | versions: 1
Installation:
bin: hello
dist
.tarball: link_to_tarball
.shasum: ce159462c166851c80e66168da61bbb11fa70c78
.integrity: sha512-5Ac8dAUvDeEMpJQen872y8eqoe8Bcl4lmpagILbu1XD4L5aEc2yrObxw3IBbCsCq7H//WE8ZeMI27sPn52TNng==
.unpackedSize: 374 B
dependencies:
figlet-cli: ^0.1.0
maintainers:
- 10io <snip>
dist-tags:
latest: 1.2.3
-> There is a bin
section.
Possible fixes
- The
bin
section appears in the json structure during the package upload. There is no need to open the package artifact to read the package.json.- Persist that section in the database (preferably in some metadata table)
- Serve that section back in the metadata endpoint