We’ve been working on a solution for a client and chose to go with Aurelia. It is a framework like Angular and since I am not fond of the complexity of Angular (and Angular2), I figured I would try it out.
Now, first things first. I am a Visual Studio guy, cause that’s what I know. But when you get to using anything web, there are web things you should know. The first is node.js.
Node.js is basically an engine for running JavaScript. In the dotnet world, when you compile to an exe, the compiler adds code to load the .net engine (clr) and then execute your code. Node.js also comes with a package manager called NPM. It’s basically an installer for node packages. Bu the way, both get installed by Visual Studio 2015 when you install all options.
The main command in npm is “npm install XXX”. This will install package XXX in the current directory (well, in a subdirectory called “node_modules”). The dependencies of XXX are installed in subdirectories also called “node_modules” in a recursive manner. In the “node_modules” folder, you will also have a “.bin” which has batch files for running the package directly.
By default, npm install will install modules locally. If you want them installed globally, you can use “npm install XXX -g”. This will install the module in a way that the .bin folder is in the path, so you can invoke the module from anywhere on your system.
Examples:
npm install manifoldjs -g
npm install jspm -g
The other part of npm is the package.json file. This file is the new do it file in the web world. If you want a package.json file, all you have to do is type “npm init” and answer a few questions. This package.json is a manifest so that if you type “npm install”, it will restore any packages mentioned in the package.json file. How do you get package entries into the manifest ? “npm install XXX –save” or “npm install XXX –save-dev”. What is the difference ? the dev packages are used to bundle, minify.. compile your application. The normal packages are directly used by your application to run.
One last thing, if you have a package.json file in your Visual Studio 2015 project, and save it, Visual Studio will invoke “npm install” automatically, hence restoring any mentioned package.
One last thing which I find fun, is that you can add a “scripts” section to your package.json. This allows you to do things like “npm run script1”, or simply get stuff automated after a successful “npm install”. Here is a reference for scripts.
Enjoy !

Leave a comment