Ask HN: How well does the Windows version of node.js work?
I'm a node developer, I've been developing on Linux and then OS X for the last decade or so (in Python before node came along).
For various reasons - mainly around hardware - I'm interested in Windows. I use Sublime, Sourcetree, git, RethinkDB, and other apps that have Windows 10 versions. I also use Sketch which has no Windows 10 version, but Adobe XD is similar.
Does anyone develop on node / Windows every day? How well does it work? Do you have issues with path length? Apps assuming path separators? Do you have issues with c modules? Do you lose productivity from random brokenness? Or is it pretty solid?
49 comments
[ 2.8 ms ] story [ 116 ms ] threadThere was always something wrong, usually in some plugin that assumed weird things about file paths. I think we submitted like 25-30 PRs to various plugins, a number of which weren't taken in because they didn't want to maintain Windows compatability.
One of the bigger issues we had was in fronting the application with IIS and logging it. It's been about 18+ months now, so the specific are foggy but our application took a long time to be resilient on Windows, to the extent that we ran the same code deployed to Windows and Ubuntu for about 8 months and primarily everyone used the Ubuntu server because it was always working.
Windows is very often not even a tested platform for most plugins, which leads to very weird things very deep in code that take quite a while to figure out.
With all of that, the Node community moves fast, so you could hope life's better now than 18 months ago- but I doubt that the community suddenly decided to add Windows to their development cycle.
In the end, we wound up with a very stable, very awesome build and deployment platform that worked great for us- and unlike all the other options we looked at, handled the gamut of C#, Java, PHP, front end only, whatever projects we had and deployed them in all the ways they'd want to be deployed. 18 months on, with little maintenance the system is supposedly still going strong- so developing Node on Windows is possible and you can make it stable, but you will very likely be doing a lot of work on other people's projects that you want to use, and you'll need to be okay with that.
The single biggest issue with Node.JS (or Python, Ruby, Lua, PHP, etc) development on windows is in my book the difficulty of setting up the build tools so that you can compile native modules. It always takes me at least an hour, as instructions seem to stop working between major OS versions, MSVC versions and the versions of whatever language you're using (relevant example: you recently had to patch psycopg2 to get it to build in the VC compiler required by Python 3.5)
Path-wise, you won't encounter any trouble: Windows accepts / just as well as the preferred \ and the OS supports long file names; it's just the tooling that's bugged. npm3 mostly solves the issue, but if you're stuck with v2, `npm install -g rimraf` to get a long-path-aware version of `rm -rf` that you can use to "reset" your node_modules folder.
So someone can (naively) concatenate paths with / and fs.readFile() and require() etc will still work?
I'm on npm v3 right now anyway for the dedupe and better shrinkwrap features so no need for extra work.
I am pretty sure it even resolves something like /Program Files/My Program correctly to C:\Program Files\My Program. We just had a lot of modules barf when they got C:\Path\whatever and were trying to parse the path by hand or do other weird stuff like split on '/'.
The issues with paths generally manifest themselves in test suites due to sloppy test (expected /foo/bar, got \foo\bar) but in practice it doesn't matter. Use path.resolve in test, fixed.
The issue with path length is almost always experienced with Visual Studio and when it is solved is because the developer moved the project to C:\ the same project works well with WebStorm.
I don't remember having issues with path separators, we even move the projects from Windows to Linux and they work without changes. There are typical recommendations when you use filesystem operations directly like using specific modules for handling paths.
Native modules are a difficult aspect of development, but this is not Node specific but general. We have similar experiences in other programming languages. We even wrote an article for a specific case http://blog.coinfabrik.com/installing-copay-in-microsoft-win...
So, we are happy developing in Windows and the native modules are the only critical aspect, but if it is just a compilation issue it can be solved with some effort.
One, the case sensitivity of file names. Two, compiled modules have not behaved well on Windows in all cases. We tend to avoid them. Three, the path length has definitely caught us. However, NPM now mitigates that with a new flatter directory structure.
Development-wise, I can't remember a single issue with node (file-watching even worked quite well). Working with Docker however wasn't nice. But I believe that changed in the meanwhile?
As a side-note: Ubuntu/Linux came a long way. I went back-and-forth between both a few times during the last ~10y. Things that scared me (window management being a big one) are a pleasure to work with in Ubuntu nowadays.
- My last Linux desktop was purchased for hardware that had 100% OSS drivers: even then compositing on an external display wouldn't work.
- The Windows machine I'm looking at has a version sold with Ubuntu. It's still pretty awful according to HN users.
I speak a lot, I need to be able to plug into every projector 100% of the time.
I use Visual Studio Code. Atom also works well. I was told that Visual Studio should also work, but apparently I'm simply not clever enough to figure out how to make it do what I want it to do.
Path length is definitely an issue; I check out all git repos directly under C:\b\ which is usually enough to work around path length issues. Path separators usually just work as Windows is rather good at translating / to \, but still it's good practice to use path.join / path.resolve rather than "hardcoding" separators.
Getting node-gyp working is black magic and it requires the recital of arcane incantations, but it's doable. However, some node-gyp modules are not very well tested on Windows and fail all sorts of weird ways. For example (and this might have been fixed since then, haven't checked in a while) the "pg-native" module (native driver for PostgreSQL) builds on Windows, but crashes when you're trying to use it. Fortunately, many native modules have JavaScript-only alternatives that you can use on Windows.
Npm works well, but due to how file locking works on Windows (you can't delete (unlink) open files), you can't always run npm update while your application is running.
Generally speaking, once you have a solid initial setup, things tend to work well. I don't run Node on Windows in production, but it performs well for development purposes.
Thanks. Could you use a Windows mount point for this?
The other aspect of this question is how often this actually is needed. I'd say it really depends on the type of development you are doing. But you can expect that any project with a sufficiently large amount of dependencies will have at least one that requires building this way. But I am surprised how often this isn't the case, and often those modules are soft dependencies.
[0]: https://github.com/Microsoft/nodejs-guidelines/blob/master/w...
If I wasn't on a spotty network ATM I'd dig through my old blog posts to find where I wrote about it. In general though, if you can get a free version of one of the VS flavors, you'll save a lot of hassle just installing that.
Things must have gone pretty bad if Azure is offering Linux now.
What is name version manager? Couldn't find anything when searching.
`rimraf` solves the issue of deleting such files and it's one of the must-have tools when doing node dev on windows, like `grep` etc
I certainly wouldn't want to try it now unless you really want to be a beta tester for Microsoft, but in a few months that may be the superior alternative for node.js on Windows.
1: https://blogs.windows.com/buildingapps/2016/03/30/run-bash-o...
- Bad npm scripts in `package.json`; usually maintainers with a severe OS X slant who don't consider that setting environment variables requires some cross-platform love (getting better though thanks to an awareness of this in the community and packages handling it such as `cross-env` and `better-npm-run`)
- Modules that require being built via node-gyp require some combination of Python 2 and VS 2010. Once these are on your PATH there is no more friction.
- Path lengths are not an initial problem with npm 2 on install but will grow to be an annoyance later. The flat(-ter) module folders provided by npm 3 is welcome.
[0]: https://github.com/Microsoft/nodejs-guidelines