Install the essentials
There is a lot of information get the MEAN stack up and running on Linux and Mac environments and less information for Windows environments, even though the process is quite straightforward. At least for this tutorial, I assume you have a machine with some version of Windows installed, along with your favourite IDE. I have Windows 7 (Not yet ready/willing to jump to 8 yet) along with Visual Studio 2013. My plan is to start with the Node.js tools for Visual Studio (More on that below) and then move on to another IDE such as Sublime Text.
Git will be used for source control. Git’s popularity can’t be ignored, and I hope to release a reasonable take sometime in the near future. Git for Windows provides all the necessary tools to get Git running on Windows, along with a nice bash shell. Despite being a sucker for Windows, I’ve always enjoyed the Unix-style commands over the command prompt.
Once MongoDB is installed, we can run MongoDB as a Windows Service (Make sure you run as administrator):
$ mongod --logpath "C:\path\to\logfile" --dbpath "C:\path\to\dbdir" --install
And to remove the service:
$ mongod –remove
Packages can be installed locally to a specific project:
$ npm install <package>
Packages can also be installed globally:
$ npm install -g <package>
For this tutorial, Visual Studio 2013 will be used to create and compile the project. TypeScript is available with Visual Studio 2013 Update 2. In the future, command-line tools will be used, so it’s worth installing now:
$ npm install –g typescript
Node.js Tools for Visual Studio is still in beta, but it provides an excellent starting point for putting together a node project, especially if you are familiar with using Visual Studio.
Create a Project
Once everything is installed, we’ll create a Basic Express Application in Visual Studio:
Upon generating the application, we get the following project:
If you’re coming from a pure .NET world, there’s some new things for you:
- The views generated are not in html, but in Jade. Jade files will be discussed in a future post.
- Style-sheets is not written in CSS, but in a pre-processor language called Stylus.
- The file package.json contains information on the npm packages the project depends on.
I see Express
If you look at the npm packages, you can see that Express is already installed as a dependency. Express sits on top of node and provides a framework to run node as a more complete web application, including the use of views, routing, etc.
I don’t see Angular
Angular is not an npm package, but it’s a framework that will be used client-side. Since the focus has been on server-side, Angular was not discussed. Angular will get its due in a future post.
Run the application
Success! We have a decent starting point, but we have quite a bit ahead. This is a good a place to take a breather.
Today we got all the necessary tools to get a simple node/express application written in TypeScript running in a Windows environment, along with having git and MongoDB installed. In part 2, I will attempt to hook up my application with MongoDB and in part 3, get angular working on the client-side.