Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Should not ignore all "node_modules" directories. #2490

Closed
jhamlet opened this Issue · 4 comments

2 participants

@jhamlet

It seems with npm version 1.1.21+ (perhaps earlier) npm is ignoring any files that fall under a node_modules directory when packaging it up.

This worked under 1.1.12.

My particular situation is using a "node_modules" directory under my "lib" directory. i.e: package-name/lib/node_modules/package-name/... npm is omitting everything from node_modules on down.

@jhamlet

Looks like this was introduced in v1.1.13 at commit: 48d9586

@jhamlet

Looks like the source of the issue lies in "fstream-npm" in #applyIgnores where it checks to see if the current directory's basename is "node_modules". If it is, it will only include items that are listed in the package.json file as bundleDependencies.

At first glance it seems like updating that check to also make sure that the "depth" of the current item is also equal to 1 would solve the problem (if there is one).

I'm not sure what the intended behavior is (beyond the comments in the source file).

Should npm ignore all items in a "node_modules" folder if those items are not listed in the bundleDependencies regardless of depth -- or, should it constrain itself to the current package root (pkg-name/node_modules)?

@isaacs
Owner

I can't see much reason for npm to treat node_modules folders special if they're not in the root of a package. That being said, this is the kind of change that can easily seem reasonable then cause problems later. I'll investigate it today.

@jhamlet

Thanks for checking into this, here's some other thoughts/info:

I'm filing this because it wasn't doing this before, and now it is breaking my package(s).

In one of my projects I have a "node_modules" directory nested under "lib" so I can take advantage of node's require behavior. Packing works as expected (or, as un-expected) with npm v1.1.12 or less.

With v1.1.13, and above, it will ignore anything that is not listed as a dependency if the current directory's basename is "node_modules". I can get npm to include my source directory if I list it as a "bundledDependency" (although, that is weird: listing your own module as a bundled dependency...)

Looking at the code, there are checks on parents, and parents of parents, so it looks like the intention was only to apply the ignores to a package's root node_modules directories...

The biggest thing (for me, and perhaps others) is my packages are now broken when publishing. If the actual expectation is that npm will ignore all things in a node_modules directory, regardless of where it is in the package hierarchy, that sounds like a major change. Also, now, to support what I am trying to do (using node's require node_modules resolution on my own package's source files) I have to add my own package name as a bundled dependency, which is counter-intuitive, and, well, weird.

@isaacs isaacs closed this issue from a commit
@isaacs isaacs Update fstream-npm
fix #2490
187b91b
@isaacs isaacs closed this in 187b91b
@isaacs isaacs referenced this issue from a commit
@isaacs isaacs Test for #2490 0c8f728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.