I am trying to integrate Angular 2 into a Sails Js application. I am new to both. I read this official textbook here. It works great offline with a static http server, but when I try to integrate into the sail application, I have the following problems:
1 - How to access angular2 js in the local node_modules folder. Every time I do this, the sails interpret it as a route and give me 404 for my scripts. For instance:
<script src="node_modules/angular2/dist/angular2.min.js"></script>
I managed to overcome the problem above using cdnjs links, but I would like to know the best / correct solution.
2 - I added the tsc and tsc -w scripts to my package.json package, but even with sails lift --verbose I don't get any output or error. This is how I added the script file in json:
"scripts": { "tsc": "tsc", "tsc:w": "tsc -w", "debug": "node debug app.js", "start": "node app.js" }
In the end, I had to install typescript with -g and compile manually. It worked, but again it is expected that it will work with scripts. It would be great to know what I am missing.
3 - After jumping through hoops to get rid of the above errors, when I raise the server again, it gives me more than 404 errors, which seem to come from system.src.js and that I cannot understand. Please view screengrab console below.

I think I could be wrong setting Angular application directories in sails. To make sure that we all cover, here is the directory structure that I use. The sail app has nothing yet. This is why the paths below are for Angular related artifacts and assets only.
In the resource folder:
application
β βββ app.component.ts
β βββ main.ts
Of course .ts files are .ts in js.
In the sails view folder I have layout.ejs which has the following contents:
. . . <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.17/system-polyfills.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.1/angular2-polyfills.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.17/system.src.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.1/angular2.dev.js"></script> <script> System.config({ packages: { app: { format: 'register', defaultExtension: 'js' } } }); System.import('/app/main') .then(null, console.error.bind(console)); </script> . . . <my-app>Loading...</my-app>
In addition to the above files, I also added tsconfig to the sails root folder.
I followed the code structure and directory recommendations from the official quick start guide.