npm publish isn't including all my files

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

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


i've had the "files" property in package.json as well (intentionaly) but used relative pathes to the list of files and directories starting with dot slash ("./"), but neither npm pack nor npm publish worked with that. removed these, all worked as expected!

so change:

"files": [ "./bin", "./lib" ]

to:

"files": [ "bin", "lib" ]

and run:

$ npm pack

check the gnu zipped tarfile and finaly:

$ npm publish <projectname>-<semver>.tgz

For anyone not fixed by the above answers, npm pack and publish respect any package.json files you have in the directory tree, not just at the root.

In my case, I had a module that templated out another module with ejs, but because npm was treating the child package.json as real it was reading the files from there and not bundling everything I needed.

Lookout for the files in any package.json, not just your root.

Tags:

Npm