npm publish isn't including all my files

npm

Solution

The problem was I had a `files` array in `package.json`. If `files` is present, then only the specified files get published, and everything else is effectively npmignored.

https://docs.npmjs.com/cli/v9/configuring-npm/package-json#files

Additionally: be aware that when there is no `.npmignore` file and the `files` array is empty the `.gitignore` file will be used. From the docs:

You can also provide a .npmignore file in the root of your package or in subdirectories, which will keep files from being included. At the root of your package it will not override the "files" field, but in subdirectories it will. The .npmignore file works just like a .gitignore. If there is a .gitignore file, and .npmignore is missing, .gitignore's contents will be used instead.

Since `.gitignore` probably ignores your `dist` folder, this may be causing problems.

Problem

I `npm publish`'d a module. It went up fine, but then when I installed it from the registry, it turned out to be missing certain files. When I run irish-pub in my module's project directory, sure enough, the output doesn't list those filenames. I've checked: - I do not have an `.npmignore` file. - I do have a `.gitignore` but this only contains `/node_modules/` - the missing files are normal JS files, not things that could be ignored by default What else could be blocking them?

Original source