3 ms·
> > tools that change their behavior based on files in one of the parent directories > You mean like git? In case of interactive tools like git it is somethin
by jwr 10y ago
> > tools that change their behavior based on files in one of the parent directories
> You mean like git?
In case of interactive tools like git it is something you would expect. But it came to me as a rather huge surprise that if you type "npm install" in a directory where you just unpacked sources, what will actually happen depends on what exists in the PARENT directory. Not to mention writing to the parent directory.
I am not alone in being caught off-guard by this: https://github.com/npm/npm/issues/2896 https://github.com/npm/npm/issues/2896
I'd say this is unacceptable in case of tools that are "make-like".
- qaq 10y agowhat's make like about a package manager?
- hugozap 10y agoIt's an npm convention according to the dependency resolution algorithm, not a flaw. If you have a .git folder in the parent directory you also get different/possibly unexpected behavior. It's not unacceptable if you have read how it works. Both cases are documented.
- rhinoceraptor 10y agoThat seems pretty normal, if I'm in a subdirectory of my project and install a dependency, it makes sense that it would install it in the root of my project where the node_modules/ folder is. When I use git in a subdirectory of my project, it looks for .git/ up the directory tree until it finds it.