I’ve had several conversations online and off with people using Windows, and the consensus is that the (vocal) Meteor-on-Windows community is small, and everyone has their own particular environment.  Many common issues arise, though, so I want to share some of my experiences should anyone else in Windowsland come across them.  It’s a little haphazard, and there might be better ways of doing things, but here it is.  Please comment with any tips or advice.

### Meteor Development on Windows 7

I use Windows 7 at my job. I’ve never used Windows 8 or 10, so I don’t know how well they will work, but they should.  The official Windows installer from Meteor has worked just fine for me.

#### MongoDB

The only thing I change about the default Meteor setup is installing a persistent version of MongoDB (as a Windows service) so I can browse, dump, and restore data when Meteor is not running. To do this yourself, create an environment variable called MONGO_URL and set it to the URL of your running mongo instance.

I’m currently running Mongo 3.0.8 locally, and have not yet tried 3.2.

#### JetBrains

For my IDE, I use JetBrains products (WebStorm and IntelliJ IDEA).  The Meteor support is top-notch.  Project setup is a breeze, code highlighting is great, clicking on template items will bring you to your helper functions, etc…  The main benefit, though, is the debugger.  You can live-debug, trace, and place breakpoints on both client and server code – all in one handy interface. Webstorm is super cheap, and 100% worth it.

### Building a Meteor App on Windows 7 (64-bit)

Running

meteor build

is where the pain begins. There are a few things that need to be done before successfully extracting a working bundle from Meteor in Windows.

An when I refer to meteor build, or bundle, I am referring to the output of the command:

meteor build --directory c:\mymeteorapp

#### More Environment Vars

You need to set ROOT_URL to http://localhost (or whatever you want) and PORT to a valid port number if you want something other than 3000. I use port 3030 so the bundled app doesn’t conflict with the development version running on port 3000.

If you are using Meteor settings, the entire json block needs to be stringified and pasted into the METEOR_SETTINGS environment variable.

The following Powershell 3.0 snippet will do this for you (assuming you run these commands from a directory with a file named settings.json):

$settings = Get-Content settings.json -Raw$settings = $settings -replace "n","" -replace "r","" -replace " ","" [Environment]::SetEnvironmentVariable("METEOR_SETTINGS",$settings, "Machine")


Please note, I am no Powershell expert (or even a novice).  Use at your own risk.

#### Build Dependencies

Visual Studio.  In order to build the fibers module (and possibly other node extensions), you’ll need some build tools.  I currently have Visual Studio 2013 AND 2015 (free Express/Community editions) installed locally.  I’m pretty sure you only need 2015, but remember to check the c++ build tools options when installing.  You don’t actually have to open Visual Studio, just have it installed.

Python. Also, Python 2.7 is a requirement. So install Python 2.7.

Node.js. You probably have NodeJS installed, but Meteor expects 0.10 (32-bit).  I’m using 0.12 (64-bit), which has gone OK so far aside from the problems listed below.  I have no idea about 4.2, or 5+.  If you want to keep your precious bleeding-edge versions of Node, I highly recommend using this: https://github.com/coreybutler/nvm-windows.

#### Situational Build Dependencies

NPM3. If you have any Meteor packages that include a very deeply nested set of node_modules dependencies, then you are going to run into the 256 character limit for file directory paths in Windows (still a thing after all these years!).  Go ahead and install npm3 (and make sure it’s install directory is included in your PATH), and we’ll use it later. To install npm3, use npm!

npm -g install npm@"3.3"

or check the GitHub wiki.

64-bit bcrypt.  If you are using meteor-accounts, then the bcrypt module is required. Because the Meteor dev environment uses a 32-bit version of node, a 32-bit bcrypt module is included with the build. To get a 64-bit version of bcrypt, you need to install Win64OpenSSL. Then go to an empty directory and install bcrypt with npm like:

npm install bcrypt --openssl-root="C:\some\other\path\to\openssl"

then dig around in the node_modules folder until you find bcrypt_lib.node. Hang on to it for later. This GitHub issue has some nice background info.

#### Meteor Build

Take a deep breath and run

meteor build --directory "C:\yourbuilddir"

This will do a bunch of things, and hopefully spit out a node application in C:\yourbuilddir.  You’re not out of the woods yet.  Go into

\bundle\programs\server

and run

npm install

.  More things will happen.  Hopefully without error (and only a handful of warnings).

If you are using bcrypt, enter the build directory and find: bundle\programs\server\npm\npm-bcrypt\node_modules\bcrypt\build\Release\ and overwrite the bcrypt_lib.node file there with the one you installed earlier.

To run the app, go into the \bundle directory and run

node main.js

from CMD. If you don’t get any ugly errors, try navigating to http://localhost:3000 (or whatever is specified in your env vars) and see if your app works.

#### Fixing the 256 character file-path limitation

Your Meteor app should run in place, even if you have some insanely long file paths.  However, copying, deleting, and pushing to a remote repo will cause problems.  The basic fix for this is to go into the offending package, delete the node_modules folder, and rebuild it with NPM3 so it uses a flat folder structure.  There are two ways (that I’ve found) to fix this problem…

If you are developing alone on a single PC, you can simply go to your global packages directory (e.g. C:\Users\<username>\AppData\Local.meteor\packages) and find the offending package with a long dependency chain.  Remove the node_modules folder, and run npm install to rebuild it with a flattened dependency tree.

This becomes problematic when updating modules or developing with a team.  Everyone will have to remember to do this every time the module is updated.  An alternative is to rebuild node_modules folders after meteor build has run.  Then it can be an automated part of your build script.

After running meteor build, go into c:\<yourbuilddir>\bundle\programs\server\npm\<package>\node_modules\<an-npm-module>\ and delete the node_modules folder.  Then run npm install from the same folder.  NPM3 should take over and install a flattened dependency tree.

### Running the build

Go into C:\<yourbuildfolder>\bundle\ and run

node main.js

You should see a blinking cursor. This is good.  Open a browser and go to http://localhost:3030 (or whatever you specified in your environment vars) and hopefully see your app running.

Coming soon… Deploying this to Windows Server 2012 behind IIS.

## 1 Comment

1. Hello,

have been trying to follow your posts on deploying meteor to windows but unfortunately I have not been able to successfully do this.
I am trying to deploy a meteor 1.5 application and so far I have been able ;
– to generate the build successfully.
– I cd programs/server && run npm install ( I got a few warning and these errors
>’node-pre-gyp’ is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@1.0.2 install: node-pre-gyp install –fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@1.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! meteor-dev-bundle@0.0.0 install: node npm-rebuild.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the meteor-dev-bundle@0.0.0 install script.

I ignored these and went on to cd into bundle and run node main.js and I got the following

>Note: you are using a pure-JavaScript implementation of bcrypt.
While this implementation will work correctly, it is known to be
approximately three times slower than the native implementation.
In order to use the native implementation instead, run

> meteor npm install –save bcrypt

>in the root directory of your application.
C:\ARBProd\bundle\programs\server\node_modules\fibers\future.js:280
throw(ex);
^

>Error: MONGO_URL must be set in environment
at Object. (packages/mongo/remote_collection_driver.js:36:11)
at Object.defaultRemoteCollectionDriver (packages\underscore.js:784:19)
at new Mongo.Collection (packages/mongo/collection.js:99:40)
at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
at fileEvaluate (packages\modules-runtime.js:197:9)
at require (packages\modules-runtime.js:120:16)
at C:\ARBProd\bundle\programs\server\packages\accounts-base.js:2019:15
at C:\ARBProd\bundle\programs\server\packages\accounts-base.js:2030:3

Please help. I am assuming the last error requires me to install mongo and somehow set the url etc. I have always run mongo only from meteor and not sure how to go about all that. Please help, i really need to get the app running on production server now.

NB: all I have done so far is still on my development environment (windows 10 64bit)