Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm publish doesn't include some files #3571

Closed
saebekassebil opened this issue Jun 17, 2013 · 3 comments
Closed

npm publish doesn't include some files #3571

saebekassebil opened this issue Jun 17, 2013 · 3 comments

Comments

@saebekassebil
Copy link

Hey guys,

I've just decided to remove my prebuilt dist/ files from my repository, since it was a pest to maintain and feels plain wrong. So I found the prepublish script, which seems perfect, but problem is, that after I switched to use prepublish my dist/ files doesn't get included when I do a npm publish!

My package.json:

{
...
  "main": "dist/file.js",
  "scripts": { "prepublish": "jake build" }
... 
}

But when I npm publish the files that the jade build command created in the dist/ folder doesn't get included!

My .gitignore is set to ignore files in dist - I don't know if that has any influence, although I know that it oughtn't.

@domenic
Copy link
Contributor

domenic commented Jun 17, 2013

From https://npmjs.org/doc/developers.html#Keeping-files-out-of-your-package

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.

(Emphasis added.)

@domenic domenic closed this as completed Jun 17, 2013
@saebekassebil
Copy link
Author

Thank @domenic that's really helpful! I would however like to note, that "Keeping files out of your package" is probably the last place I'd have looked.

May I also add, that it seems to me that npm has nothing to do with my .gitignore file, and shouldn't speculate on which files to add by looking at it.

NickTomlin added a commit to NickTomlin/mailchimp-lite that referenced this issue Sep 18, 2015
@slurmulon
Copy link

Hi all, just wanted to share a useful tip for developers who prefer not having to commit build output folders (like myself!)

If you wish to publish your build/dist folder to NPM but not have to commit it, simply touch .npmignore (creates an empty file).

There is an implication, however, in that NPM can start publishing files that you wouldn't normally expect it to because they have always been elegantly detected in your .gitignore, so be sure to keep that in mind and stay explicit.

Source: http://stackoverflow.com/a/24942436

olsonpm pushed a commit to olsonpm/child-process-promise that referenced this issue Aug 15, 2016
 - See npm issue for explanation
   npm/npm#3571
   In short, files matched in .gitignore are ignored by npm publish if .npmignore is not found
bcherny added a commit to bcherny/json-schema-to-typescript that referenced this issue Sep 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants