Why doesn't npm comply with user / global npmignore?

My editor creates workspace files and backup folders that are not of interest to users of the software that I write. To avoid having to list my editor-ignored ignorance in each project, I try to tell npm to ignore them at the user level or globally.

Unfortunately, I’m out of luck. Running npm pack inside my project folder, even if I first cleared the npm cache, includes both a workspace file and two megabytes of backup files. (For a project with ten kilobytes of code!) I tried ignore configuration settings, for each user .npmignore and global npmignore , all this does not affect.

Here is my output from npm config ls -l , tied to the relevant sections:

 ; userconfig C:\Users\benblank\.npmrc ignore = "__history *.epp" ; builtin config undefined prefix = "C:\\Users\\benblank\\AppData\\Roaming\\npm" ; default values globalignorefile = "C:\\Users\\benblank\\AppData\\Roaming\\npm\\etc\\npmignore" userignorefile = "C:\\Users\\benblank\\.npmignore" 

And the (same) contents of C:\Users\benblank\.npmignore and C:\Users\benblank\AppData\Roaming\npm\etc\npmignore :

 __history *.epp 

What am I doing wrong? I am running Windows 7, node @ 0.8.9 and npm@1.1.61.

+7
source share
1 answer

npm has some basic obscure issues related to npmignore files.

Fortunately, there is an even better alternative! This is a property of package.json files .

Here is an example from my delivr project.

 "files": [ "lib", "index.js" ] 

Why is it better?

  • Internal technology makes this mechanism more reliable.
  • This is a white list instead of a black list. Usually, assuming you are using the lib folder (or similar), there are fewer files / directories that you want to include instead of the ones you want to exclude, so this is more concise.
  • DRY . If a .npmignore file .npmignore , npm will not access .gitignore for ignore patterns, which often require duplication and duplicate information. This issue does not exist using the whitelist.
  • Another file in the repo. package.json already the manifest that defines your package, and it creates a ton for this configuration to live there.
+2
source

All Articles