Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm publish isn't including all my files

Tags:

npm

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?

like image 434
callum Avatar asked Nov 20 '14 20:11

callum


People also ask

What does npm publish include?

When you run npm publish , npm bundles up all the files in the current directory. It makes a few decisions for you about what to include and what to ignore. To make these decisions, it uses the contents of several files in your project directory.

Does npm publish use Gitignore?

In simpler terms, npm prefers the . npmignore file if it is there, but will fall back to the . gitignore file. In many cases, both Git and npm can ignore the same files, so it makes sense to just use a .

Does npm publish overwrite?

By default npm will publish to the public registry. This can be overridden by specifying a different default registry or using a scope in the name (see package. json ).


1 Answers

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

like image 118
callum Avatar answered Sep 24 '22 05:09

callum