[bug] .npmignore can't exclude .npmignore

(Bluelovers) #1

What I Wanted to Do




  • .npmignore
  • lib/
    • lib/static/
      • lib/static/.npmignore

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 -->

(Erick Wilder) #2

.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)

(John Gee) #3

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!]


(Bluelovers) #4

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)

(Bluelovers) #5

anthor bug

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

(John Gee) #6

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'));

(John Gee) #7

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