TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Node's nested node_modules approach is basically incompatible with Windows

63 pointsby tsingalmost 11 years ago

20 comments

girvoalmost 11 years ago
Know the biggest issue I've had with Node (well not me, but my colleagues)? That modules have a habit of using symlinks, which break horridly across Vagrant/VirtualBox shared folders. We ended up fixing it somewhat by using the --no-bin-links option on `npm install` and swapping over to SSHFS, but I really wish module writers would pay more attention to Windows... one of Node's strengths is that it works pretty darned well on Windows (just like how XAMPP made PHP deal with windows well enough for a large developer base to grow)
评论 #7914761 未加载
评论 #7915284 未加载
评论 #7914753 未加载
评论 #7914956 未加载
addisonjalmost 11 years ago
I am somewhat surprised at this topic. Of all the the issues Node.js has on windows, this seems like a fairly minor one. In my eyes, the biggest issue is simply this:<p>A lot of module writers don&#x27;t care about Windows.<p>A big part of the node ecosystem is that there is a module for practically anything. While node core has great support for windows, and also helps aid developers in writing code that is windows compatible, from what I have seen, its not often followed.<p>Any number of simple things break modules on windows, using a &#x27;&#x2F;&#x27; as a path separator instead of path.join, native modules, bash or shell scripts used in pre- or post-install scripts and probably a hundred other small ways to screw it up. Even trying to make your own module Windows compatible is often thwarted by a dependency that doesn&#x27;t. Like Java&#x27;s promise of &quot;Write once, run anywhere&quot;, its a great idea, but hasn&#x27;t completely panned out.<p>I really hope that as the node community matures, there can be more of a focus on making sure things work on Windows. Node is a great platform partially because of all those modules and getting them all working will make writing cross platform apps and services a heck of a lot easier.
评论 #7915313 未加载
lucisferrealmost 11 years ago
I actually find it surprising how many people feel recursive node_module dependency folders is justified. It seems absolutely the worst possible solution to me. Am I misunderstanding something about this. Is there any reason Bundler&#x27;s approach doesn&#x27;t work here?<p>It seems ridiculous to me how many folders are created when I just need a couple of node modules to do something.
lucisferrealmost 11 years ago
This is going on a bit of a tangent, but even Visual Studio used to run up against this problem all the time using some of Microsoft&#x27;s own libraries. It was laughable at the time, but some of Microsofts teams (<i>cough</i> Patterns &amp; Practices <i>cough</i>) loved to created DLLs with huge long namespaces. That coupled with the fact that Visual Studio projects were created in &#x2F;Users&#x2F;User.Name&#x2F;Visual Studio&#x2F;Visual Studio ##&#x2F;Projects&#x2F; to begin with created a lot of problems.<p>As a result I almost always put all my projects at the root something like &#x2F;src to reduce the odds of running into these problems.
dbboltonalmost 11 years ago
This definitely seems more like a Windows issue than a Node issue.
评论 #7914705 未加载
评论 #7914788 未加载
rtpgalmost 11 years ago
Was the recursive &quot;every package include its dependencies&quot; done just because it was easier? Or was it a conscious design choice.
评论 #7914669 未加载
评论 #7914639 未加载
abhididdigialmost 11 years ago
The title looks exaggerated. I thought NodeJS cannot just run on Windows anymore. It&#x27;s not the case though, it does - it&#x27;s just it creates folders that are nested.
评论 #7914694 未加载
derefralmost 11 years ago
I&#x27;m surprised the obvious solution isn&#x27;t already implemented universally by package managers: checkout the modules into a single directory, named as &quot;[name]-[commit SHA]&quot;. You get all the benefits of the current system, with the added benefit that if A and B both turn out to want to check out C#1a029fb, then you only get one copy.
评论 #7914836 未加载
frikalmost 11 years ago
The Win32API was initially designed to make it very easy to port from Win16API in the early 1990s. Microsoft neglected to improve the Win32API starting with the dotNet adventures. Instead of an improved Win64API we have the identical API for 32 and 64 bit (and WinRT API). The shell still doesn&#x27;t support UNC path. The Windows NT series operating system would support different subsystems other than Win32.<p><i>Naming Files, Paths, and Namespaces</i> on MSDN explains the details: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx" rel="nofollow">http:&#x2F;&#x2F;msdn.microsoft.com&#x2F;en-us&#x2F;library&#x2F;windows&#x2F;desktop&#x2F;aa36...</a>
linhmtran168almost 11 years ago
Have the same problem. Although I&#x27;m a Mac user, but I&#x27;m using OneDrive to store some toy projects. OneDrive stopped working and complained about the long folder path when I tried to install a NPM package. After some researches, I know this problem will not be fixed soon and move all of my Node projects to DropBox. For Windows user, I think the only solution now is to use a VM.
wolfgkealmost 11 years ago
Windows does support long paths (up to about 32k characters): Here is a good explanation from the .net perspective (but the same holds for non-managed APIs): <a href="http://blogs.msdn.com/b/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx" rel="nofollow">http:&#x2F;&#x2F;blogs.msdn.com&#x2F;b&#x2F;bclteam&#x2F;archive&#x2F;2007&#x2F;02&#x2F;13&#x2F;long-path...</a><p>Long paths are just most ugly to use: &quot;Long paths with the \\?\ prefix can be used in most of the file-related Windows APIs, but not all Windows APIs. For example, LoadLibrary, which maps a module into the address of the calling process, fails if the file name is longer than MAX_PATH. So this means MoveFile will let you move a DLL to a location such that its path is longer than 260 characters, but when you try to load the DLL, it would fail. There are similar examples throughout the Windows APIs; some workarounds exist, but they are on a case-by-case basis.&quot;
pingecalmost 11 years ago
Long paths are a PITA on Windows sometimes :(. A while ago I had a problem with long node module paths and msysgit. Luckily, this was fixed in v1.9.0<p><a href="http://pingec.si/blog/articles/msysgit-longpath/" rel="nofollow">http:&#x2F;&#x2F;pingec.si&#x2F;blog&#x2F;articles&#x2F;msysgit-longpath&#x2F;</a>
asavialmost 11 years ago
The easiest solution I&#x27;ve found is to just run a VM and not sync whatever folder you install node_modules in. I just had this problem like a week ago with gulp because I was syncing the folder I was building in. It&#x27;s a good time to learn how to use Vagrant.
评论 #7915144 未加载
pickettdalmost 11 years ago
So far I&#x27;ve been able to get by in Windows (for my projects at least) if I use Cygwin for interacting with paths that are longer than MAX_PATH. For example - if a project has node_modules committed in git then I have to clone the repo using Cygwin. This doesn&#x27;t help with the problem related to install scripts on deeply nested components though because npm doesn&#x27;t support Cygwin. In Windows I still run npm and node commands in a regular command prompt.
dovertonalmost 11 years ago
I ran into this yesterday, having tried to install yeoman into a folder shared between a windows host and a linux vm. Ended up with files which could not be deleted by any other way than from the windows command prompt using the 8.3 filenames.<p>An hour of swearing was enough to convince me to stop using windows for this entirely.
rgawdzikalmost 11 years ago
What percent of the node.js community will this effect?<p>What&#x27;s the design reason for Windows tools to only have a max of 260 file path chars? If it&#x27;s not the OS, but the tools he is using, why not use tools that work? Isn&#x27;t this the tools bug?<p>Honestly, if he is doing web development, his life will be easier with a linux distro.
评论 #7914742 未加载
aikahalmost 11 years ago
isnt it the reason why python ,ruby and co install themself in &#x2F;c&#x2F; by default? I always wondered why they did that. PHP and Java dont have this problem(but &quot;hello&quot; package conflicts...).
tsmashalmost 11 years ago
Entering my serious vote to end node development on windows
rmrfrmrfalmost 11 years ago
I can&#x27;t stand hostile issue submissions like this.
panarkyalmost 11 years ago
This looks like a Docker container on Digital Ocean.<p>I would use this a lot, but many errors trying to apt-get install packages.