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

cli
help-wanted
good-first-patch
triaged

(nixx) #1

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.

Details

https://docs.npmjs.com/files/package.json

Certain files are always included, regardless of settings:

  • package.json
  • README
  • CHANGES / CHANGELOG / HISTORY
  • LICENSE / LICENCE
  • NOTICE
  • The file in the “main” field

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


(Lars Willighagen) #2

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.


(Kat Marchán) #3

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

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


(nixx) #4

I’ve submitted a PR at https://github.com/npm/npm-packlist/pull/19