Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for .node_modules (hidden dir) #2890

Closed
lquixada opened this Issue · 25 comments
@lquixada

Any chance to add support for .node_modules/? Just like .git/?

My project structure would be a lot cleaner if the node_modules/ could be hidden. Maybe add it to the lookup path.

@isaacs
Owner

Not ever going to happen. Sorry.

@isaacs isaacs closed this
@isaacs
Owner

You can do this if you really are offended by seeing node_modules in your directory structure:

# add to ~/.bashrc
ls () {
  ls "$@" | grep -v node_modules
}
@jasonkuhrt

Dup #2734

Except @isaacs did not drop me a nice hint : )

@jasonkuhrt

@isaacs Could you point me to the original discussion that sealed this decision?

@jasonkuhrt

@lquixada For vim users using nerdtree you can put this into your vimrc:

let g:NERDTreeIgnore=['node_modules$[[dir]]']

@sindresorhus

Not ever going to happen. Sorry.

Does anyone have a link to the reasoning behind this? I couldn't find anything..

@moreindirection

Why is this "never going to happen"? node_modules really pollutes my home directory.

@isaacs isaacs reopened this
@isaacs isaacs closed this in 09d51c3
@isaacs
Owner

Fixed the documentation bug.

@sindresorhus

Hah, I should have been more clear... I was looking for the reasoning behind not going with a hidden folder at the beginning? (for curious reasons, I don't care that it's not hidden today)

@moreindirection

Same here - I don't care about the actual name of the folder, I just want it to be hidden, so it doesn't clutter up my home directory. I don't use Node that much - I don't need to see the modules folder every day.

Call it 'susan' if you want, as long as it's hidden.

@isaacs
Owner

Well, it's too late to change now. @ry had an opinion about the name of the folder, and I didn't, and there was some opinions floating around that dot-folders are weird on Windows. So here we are, years later.

@svoop

@isaacs Why not use .node_modules if it exists and create node_modules otherwise? All users would see the visible directory after install and Windows is happy. Those on Mac and Linux who wish to hide it could then just mv node_modules .node_modules.

@svoop

@robertkowalski Well, amen then :smile:

@chrishough

although this will never happen, it does not mean the current setup is pretty. it's down right ugly. I agree +100 to renaming that mess.

@guybrush

pretty, ugly, a mess? those are relative terms :p

for me its pretty like it is because its simple and just works

also i really dont understand why someone would prefer .node_modules over node_modules, what exactly is the difference?! if you dont want to see it, write a bash-script to hide it? you could even write a bashscript to translate node_modules to what-ever when displayed on a tty. its insane to demand such a huge, fat and dangerous change in node just because you dont like how a folder is named. i guess you dont like /dev, /var, /home either? ask your distro-maintainer to rename it..

@chrishough

Not trying to start a troll war here, just offering a +100 and agreeing with my peers here who originally asked for it. It is pretty common in unix that config directories use .folder instead of this approach. I am merely agreeing it looks like clutter versus something like .bundle for example.

@moreindirection

Right, it's silly for me to look at my directory and see a "node_modules" directory there. My installed Node modules are plumbing, they're background - I don't need to see them front-and-center with my project folders. And there's no way to "write a bash-script to hide" this folder. If it were simply prefixed with a dot (cf. git, GHC, cabal, maven, sbt, SSH, CPAN, RubyGems), then it would be a much better citizen of the Unix filesystem. Separate from whether or not it's straightforward to make this change after Node's been out there in the world for such a long time, we should at least be able to agree that the dot prefix is preferable.

@othiym23
Owner

Maven, Leiningen and sbt have a dot-prefixed cache folder (the same one, in fact -- $HOME/.m2), but so does npm ($HOME/.npm/cache). They store your project's individual dependencies in a top-level, non-dotted folder inside your project, just like npm. It just so happens that those modules are bundled inside JAR files rather than being exploded on the filesystem, but the principle is the same.

As for gems, either you have a global set of modules with fairly thingy version resolution (similar to using CPAN – not something I personally miss dealing with, though YMMV), or you have bundler, which brings its own set of complications. I don't know about you, but I spend a decent amount of time in my node_modules folders, and it makes sense to me that it's a first-class part of my project. Dependencies are a first-class part of Node projects (as is vendor in Rails projects, or the aforementioned mvn / lein / sbt JAR folders). It absolutely makes sense to me to have them visible by default.

@isaacs
Owner

@othiym23 That is roughly what @ry's opinion was back in 2011, iirc. Because it varies project-to-project, it should be visible, because it's part of the project, like the "deps" or "libs" folder in most C programs, or "vendor" in Ruby programs. I just didn't care. The dotted-ness of .git folders never stopped me from looking in there. It just makes it sort at the top, which actually is a little presumptuous ;)

Rather than opening it up for wasteful bikeshedding, we just made a decision and moved on. Smart people can honestly disagree on it, precisely because it is a subjective bikeshed, but the much more important consideration is just not to increase complexity without significant objective gain. Since the pattern is so established at this point, it would increase both complexity and confusion to introduce the suggested change. That is the worst thing to do to a module system, since it's such a critical interface.

@sergeymorkovkin

Maybe you could at least make it an option and leave developers responsible for any consequences?

@drewnoakes

Renaming to .node_modules (or at least allowing this somehow) would naturally work correctly with several tools that treat dot-files as hidden (such as tree). Is it possible to configure a central node_modules folder? I only really want this thing to be outside of my project directory (or invisible).

@StreetStrider

For current state of things it is interesting that node_modules is not so «node», because of other environment called io.js. npm manifests itself as «package manager for everything [in js]». So I think it should name its directories in compliance with this fact.

In my opinion the better name is: .js_deps.
1. It starts with dot, so it is not showed in listings by default.
The problem not in listing, but in fact that if developer want to hide this directory, he should tune every utility he uses: ls, find, tree, window manager, gui-search, or panel manager to do so. Dot will allow to hide directory by default in all unix-like and I believe it is possible to hide this directory on systems like windows by manipulating attributes.
2. It is not sounds like something node-related.
npm packages can be used in frontend projects in pair with CommonJS bundlers. It can be used in io.js. Many other may follow, like nodeos and jxcore
3. It is much more shorter.
And defers path-length problem on windows.

As was mentioned before, it can be introduced as optional place to search for. And then smoothly migrated.

@othiym23
Owner

As mentioned a number of times, this is baked into both node's module resolution code (whether it's Joyent-branded Node.js or io.js) and npm. Nobody involved in the core development of any of the related projects has any interest in changing this or repainting the bikeshed. This is not going to change.

@othiym23 othiym23 locked and limited conversation to collaborators
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Something went wrong with that request. Please try again.