npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

[bug] .npmignore can't exclude .npmignore

What I Wanted to Do




What Happened Instead

when publish, /lib/static/.npmignore still got ingore

Reproduction Steps


Platform Info

$ npm --versions
<!-- paste output here -->
$ node -p process.platform
<!-- paste output here -->

.npmignore should be placed in the root directory of your package. By your example I assume that it is not (i.e., under lib/static/.npmignore)

You don’t want the exclamation point starting that line. It negates the pattern, and I think that will mean exclude everything except this file. The opposite of what you are trying to do. [edit: oh, on reread it is what you are trying to do!]

i know where .npmignore should put

but /lib/static/.npmignore this file is tpl file for create new module

im doing something like this

fs.copy('./lib/static', target_path)

anthor bug

can’t ignore */**/*.md

This is a work-around for the behaviour you encountered. I do not know if the current npm behaviour is as intended, but this suggestion will hopefully let you achieve what you want with the .npmignore file.

A common pattern for template files is to call them something else and rename them to the “real” name when preparing them. This might work well for your case.

You could call your file: /lib/static/npmignore.template

and in your code do something like:

fs.copy(fs.join('./lib/static', 'npmignore.template'), fs.join(target_path, '.npmignore'));

What were you expecting this to do? (Ignore .md files in folders but allow .md at the top level?)