Node.js development, windows or linux?


I'm interested in web development on the Node.js platform. My host OS is Windows 7. What would be the preferd way to set up a development environment. Run it directly on the host or in a linux based virtual machine? What are the pros and cons between these two methods?

If I go with a VM, can I still run the text editor and web browser in Windows (for performance reasons)?

9/25/2012 10:49:31 AM

Accepted Answer

We have a system via which we just use a config file, which handles all our problems like path differences ("c:\blarg" vs "~user/blarg") and, as a bonus, lets us control differences between debug and production environments.

Node.js is cross platform, so we totally have developers working on all sorts of computers, and it's no problem at all.

This is an example config file I use on a file storage project:

 * All of these are mandatory except for log_level (which defaults to "info", 1) 
 * and log_echo_to_console (which defaults to false)
exports.config = {
    log_level: 0,
    log_file: "/path/to/send.log",
    request_log_file: "/path/to/send_requests.log",
    log_echo_to_console: true,
    port_number: 8088,
    no_notification_emails: true,
    image_url_base: "",      // MAKE SURE THIS ENDS IN "/"
    s3_info: {
        key: 'xxxxxx',
        secret: 'yyyyy',
        file_bucket: 'sendtransfer/',
    backend_info: {
        db_info: {
            server: "localhost",
            user: "db_user",
            password: "secret",
            database: "SendRemote",
            pooled_connections: 125,
            idle_timeout_millis: 30000
        memcache_info: {
            host: "",
            port: "31111",
            pooled_connections: 200,
            timeout: 20000

    debug_server: true

For Windows machines, just change the paths. It's all good!

Then in code, you can just type:

var local = require('local.config.js');
// etc

Embrace multiculturalism!!!

9/25/2012 1:38:23 PM

Eh from experience, use Linux Docker.

edit Use Docker. bake in your dependencies, mount your project at run time, pin to a particular version of LTS node only. I'd take a 2gb docker image over un-runnable project leading to days lost being forced to upgrade to new packages. - 2018/04/10

But from someone whose spent the last 8 years developing in a linux based environment, and having spent the last 6 months developing software using nodejs in a windows dot net environment, here are my discoveries, shocking or otherwise...

Problems on windows:

  • can't effectively utilise docker Latest version of the docker toolkit solves this as far as I'm concerned. ymmv.
  • most node modules require node_gyp, which on the surface doesn't seem problematic (since gyp is supposed to be cross platform compiler), except when you delve into what it takes to get this working on windows: nothing short of installing visual studio will work. This sucks for me due to several reasons:
  • I'm normally on linux, so I never want to have to use visual studio.
  • It's entirely the most ridiculous idea that compiling something on windows requires at minimum a 3GB installation of an IDE... not libs but an entirely monolithic piece of GUI software I'll never ever launch.
  • the windows equivalent of debians build-essentials is actually a disparate sprawling ill named collection of gui only installers scattered across the internet all requiring a specific installation sequence. This, compared to sudo apt-get install build-essentials is overly time consuming and fraught with hidden gotchas.

  • developing on windows will allow you the bad habit of mixed case path names, unless your team either has a strict policy that is followed/enforced this will be a slippery slope to problems later on.

  • while windows supports more than 256 characters in paths, important tooling through out does not. enter stage left: rimraf and robocopy... ugh.

  • the windows terminal sucks... so does the default shell: cmd.exe... Powershell is far too verbose in it's syntax and not to my taste... Installing Cmder aleviates this somewhat, however the only way for Cmder to interface with cmd.exe is to basically copy keystrokes to a hidden windows terminal running cmd.exe. (lolwut). Cmder works a lot better with shells that a more modular (zsh, bash, etc).. update: I now use powershell with pshazz and scoop, which is actually pleasant to use.

  • Having still improved the shell and terminal situation, nodejs for windows will still assume your environment variables are %OF% %THE% %WINDOWS% %VARIETY%... not the $UNIX $STYLE. So you'll basically be using bower and npm mostly from cmd.exe... more ugh. I dont' seem to be having this issue anymore since I've incorporated a mix of cross-env and commander or yargs.

    • You'll also need to install python for windows, not a problem because choco exists and has you back there. update: have a look at boxstarter, will help automate your new machine setup with recipes (or you could actually graduate to using ansible or salt).

    • experienced python, ruby developers will tell you that old projects will need the version of their engine silo'd for when you need to revisit them (upgrading to newer versions is mostly not expedient or practical, read: rabbit holes), so you'll want something like rvm and virtualenv...

    • nvm (which only works on unix systems linux and macosx) because it's a collection of bash scripts. I recommend using ZSH as your shell along with Zgen and Tarrasch/zsh-autoenv plugin.

    • nodeenv, which is more likely... a python program that integrates with virtualenv. Some people like this. I have no problem with it, but our team uses nvm.
    • however, you're better off with nvm-windows because "reasons". scratch that, use nodist on windows... bar far the better choice, you won't need to worry about some kind of autoenv since nodist by design handles this.

Installing on Windows:

  1. install chocolatey
  2. choco install cmder nodejs python2 choco install python2
  3. install, then use it to install pshazz.
  4. remove any versions of node manually installed globally.
  5. install nvm-windows install nodist.
  6. install visual-studio 2012 express, then never launch it if you treasure your cpu cycles. this may be overkill as microsoft have released an equivalent to build-essentials.
  7. install windows 7/10 64bit sdk

Problems on Linux:

tldr; use nvm. for more reasons other than the below.

  • you'll have to set the global npm node_modules path to a user owned directory (I've started using ~/.local/share/npm). Pleasantly, this is something I found the windows installation of nodejs got right (probably not intentionally). A non issue when using nvm.
  • Ubuntu already has a binary called node, so #!/usr/bin/env node will by default not run nodejs. luckily debian systems have a neat management tool for controlling what the env binary emits: update-alternatives. ignore suggestions to use symlinks here, which will only cause problems later on in subtle ways. also a non issue when using nvm.

Installing on Linux :

$ sudo apt-get install git-core git-flow build-essentials python-dev python-  pip
$ curl | bash
$ npm config set prefix ~/.local/share/npm
$ nvm install stable
$ nvm alias default stable


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow