@@ -27,6 +27,7 @@ npm install postinstall-build --save
2727- [ Caveats] ( #caveats )
2828 - [ Bugs in Yarn] ( #bugs-in-yarn )
2929 - [ Bugs in npm] ( #bugs-in-npm )
30+ - [ Excluding source files via ` .npmignore ` or ` files ` ] ( #excluding-source-files-via-npmignore-or-files )
3031 - [ Building a file referenced by package.json ` bin ` ] ( #building-a-file-referenced-by-packagejson-bin )
3132
3233<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -261,6 +262,21 @@ my knowledge they are no fault of this package and are widely reported npm bugs.
261262 ` npm config set fetch-retries 5 ` (for example) to work around this; using the
262263 non-HTTPS registry might also help.
263264
265+ ### Excluding source files via ` .npmignore ` or ` files `
266+
267+ When npm installs from a Git repository or any other non-package location, it
268+ will first prepare the directory as if it were publishing a package. This
269+ includes respecting the ` .npmignore ` file and ` files ` field in ` package.json ` ,
270+ which means that ` postinstall ` scripts are executed with a subset of the files
271+ you may need to run your build step (if you have ` .npmignore ` or ` files `
272+ configured). Thus, in order for ` postinstall-build ` to work, you should ** not**
273+ ignore the source files or any necessary configuration (for example, ` .babelrc ` ).
274+
275+ This is not ideal, but it’s how npm works. If you are determined to exclude
276+ unnecessary source and configuration files from the published npm package,
277+ you may want to consider a publishing step that alters the ` .npmignore ` or
278+ ` files ` settings.
279+
264280### Building a file referenced by package.json ` bin `
265281
266282If your ` package.json ` file uses the ` bin ` field, and any of the referenced
0 commit comments