npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm files field doesn't implicitly include files in bin field

What I Wanted to Do

I made a package that uses the “bin” field in package.json. When you use the “main” field, that file is implicitly included in the final package, even if it isn’t in the “files” field.

What Happened Instead

The “bin” file was not included.

Reproduction Steps

Make a file called bin.js containing anything and a package.json containing the following:

  "name": "bug",
  "version": "1.0.0",
  "description": "",
  "bin": "bin.js",
  "files": [],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "",
  "license": "ISC"

Call npm pack. Note that bin.js isn’t included.


Certain files are always included, regardless of settings:

  • package.json
  • The file in the “main” field

If “bin” files are specified, they should be included.

Should probably be inserted here:

If someone wants to make a patch (I don’t have time this weekend): be aware that the bin field can have multiple entries.

This is a feature request in disguise. Moved to #ideas.

I wouldn’t be opposed to a PR for this though.

I’ve submitted a PR at