5 ms·
I use Node on Windows regularly as I have a client whose stack is mostly based on .NET, but they recently started using Node as well. I use Visual Studio Code.
by DrJokepu 11y ago
I use Node on Windows regularly as I have a client whose stack is mostly based on .NET, but they recently started using Node as well.
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.
- nailer 11y ago> I check out all git repos directly under C:\b\ which is usually enough to work around path length issues. Thanks. Could you use a Windows mount point for this?
- kek918 11y agoJust wanted to add that at my workplace we regularly set up extra drive mounts just to get around the long path issue and it works fine. For instance we map G:\very\long\file\strucutre\ to X:
- manyxcxi 11y agoThat's what we did and found it to work great for us. Occasionally we still had some that were just too long and had to hack about them.
- bryanlarsen 11y agoHave you tried npm 3? Does its flattening solve your path length issues?
- DrJokepu 11y agoYes, I use node 5 and npm 3 and it improves the situation. That being said, npm 3 won't help if the project's folder structure is itself deeply nested.
- t1amat 11y agoVisual Studio is an extra source of issue since it packages its own version of nodejs and with it npm. You can configure Visual Studio to use your global nodejs, however. I have mine setup this way, and Visual Studio uses my global nodejs 5 and npm 3.
- nailer 11y agoDo you need Visual Studio for its C compiler? Or can you get by without it (eg, is there another compile you could use to build native stuff)?
- t1amat 11y agoAs far as I am aware, on Windows, for C/C++ modules that need compiled, there are no options other than Visual Studio. I have to qualify this by saying that I have had an MSDN license for a decade and haven't been forced to find a work-around. If you could find a Community Edition of it that would probably be enough. 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.
- numo16 11y agoBased on Microsoft's node.js guidelines[0], it looks like you should be able to get by with just installing the Visual C++ Build tools and not the full VS community edition. [0]: https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#configuring-your-windows-development-environment https://github.com/Microsoft/nodejs-guidelines/blob/master/w...
- manyxcxi 11y agoThere are command line tools/minimal libraries that allow you to compile C/C++ provided in the depths of Microsoft's webs that can/will let you do this without a full on VS install. Typically good for setting up a build server/etc. 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.
- manyxcxi 11y agoAh, node-gyp. I completely forgot about all the f@$king problems that caused us.