gitignore trumping empty npmignore in npm 5.4.2 and above (not previously)

What I Wanted to Do

My gitignored, generated files to be published when running npm publish

What Happened Instead

gitignored files were not published (except the one that main pointed to and only when using npm 5.4.2 and above)

Reproduction Steps

Original investigation of this issue

  • Start with any npm repo
  • Do not have a files array in your package.json
  • have a .gitignore that ignores a dir ('say lib/)
  • have an empty .npmignore so that npm doesnt default to using the .gitignore
  • run npm pack and untar the tar file
  • if running in npm 5.4.2 or later, you will not see your gitignored files

Alternatively

You could checkout this commit and run npm pack using npm 5.3.0 and again using npm 5.4.2

$ rm -rf cz-lerna-changelog-2.0.2.tgz package
$ npm pack
$ tar -xzf cz-lerna-changelog-2.0.2.tgz
$ ls package/lib | grep autocomplete

Details

The docs say:

Use a .npmignore file to keep stuff out of your package. If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it.

It looks like this was the case until somewhere between npm 5.3.0 and 4.2.0 (see screenshot below)

Platform Info

$ npm --versions
 {'cz-lerna-changelog': '2.0.2',
  npm: '5.4.2',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.7.0',
  openssl: '1.0.2l',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.42',
  zlib: '1.2.11' }
$ node -p process.platform
darwin

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.