Skip to content

Instantly share code, notes, and snippets.

@austinsc
Created March 6, 2015 16:27
Show Gist options
  • Select an option

  • Save austinsc/70efda0c467f639f5153 to your computer and use it in GitHub Desktop.

Select an option

Save austinsc/70efda0c467f639f5153 to your computer and use it in GitHub Desktop.
Node.js on Windows

Node.js is a portable javsacript runtime that uses the Chrome's V8 engine to execute scripts outside of the browser. Click here to learn more about node.js

Step 1: Install Node.js

If you like clicking the next button on installers, you can go to http://nodejs.org/ and download the latest version of node for Windows. Once it is installed, proceed to step 2.

OR

If you want to look like a 1337 computer hacker, do it the chocolatey way. Open up a new command prompt as an administrator and run the following command:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Great news! Now you have a package manager for Windows! The next step is to install the node.js package. You can do that with this command:

choco install nodejs.install

Step 2: Install Git

Github.com is chock full of amazing front end frameworks. In order for our build system to access them, we need git installed.

Once again, you have two choices- install the old fashioned way or use chocolatey. To install from a browser download, go to http://git-scm.com/download/win and grab the latest version. Note: when you install with the gui installer, make sure you select the option to 'Use Git from the Windows Command Prompt'

Or, simply type

choco install git.install

Step 3: Confirm %PATH% has all of the prerequisites

Open up a fresh command prompt instance and verify that node and npm are available on the system path. The easiest way to do this is to type in where node and where git in the command prompt. Both of these commands should return valid local paths to their respective excecutable files.

It is worth noting that your path variable in Windows can only be 260 characters. If you run out of space in your path, you will have to remove a couple of the useless entries to make room for node and npm. The result of set path should include both %APPDATA%\npm and C:\Program Files\nodejs as well as the directory containing your git installation.

Step 4: Install Bower and Grunt

Now that the hard stuff is done, you can grab a couple of tools from npm and add them to your global node packages folder. This command will install both bower and grunt's command line task runner globally.

npm i -g grunt-cli bower

Step 5: Install the Project's Dependencies

Almost there- browse to the project directory (the folder containing the .csproj file) in your command prompt. Next, type npm i and press enter to install all of the node modules registered in the package.json.

For your convenience, we have added a post-install step that will automatically download and install the bower packages as well. To acheive the same result manually, you would have to use the bower install command after the npm i process finished running.

Step 6: Fire up the Live Reload Server (optional)

If you are ready to get working on front end components, type grunt serve to start up the livereload socket.io server. This will watch for changes on css/less/js/html/cshtml files and automagically push them to your browser (no refresh required).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment