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)?
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...
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.
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.choco install cmder nodejs python2
choco install python2
http://scoop.sh
, then use it to install pshazz.tldr; use nvm. for more reasons other than the below.
~/.local/share/npm
). Pleasantly, this is something I found the windows installation of nodejs got right (probably not intentionally).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.$ sudo apt-get install git-core git-flow build-essentials python-dev python- pip
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash
$ npm config set prefix ~/.local/share/npm
$ nvm install stable
$ nvm alias default stable
references: