1

Background

I am migrating one of the apps from Angularjs 1.x to Angular 2. Being new to the Angular 2 , I am first trying to get grasp of different files used for configuration

Before jumping to my app, I created a small dummy app with the help of quickstart files from Angular Quickstart on gitub

https://guthub.com/angular/quickstart

I move those files into a .NET MVc 5.0 web app. When I build the app using the npm CLI

npm start 

It creates an index.htm, and that successfully ran. My next step was to use a MVC View instead of this index.htm, This time, I created a default route for localhost/ pointing to PublicController with a view Index.cshtml.

Problem Statement

While using MVC views, routed through Controllers, what I see is that main.ts file when compiled omits the file extension - *.js For e.g.

import { AppComponent }  from './app.component';

in my Main.ts, when compiled translates to (in main.ts)

var app_component_1 = require("./app.component");

My page ran with a console error, and I saw 404 error for not been able to resolve app.component.

All works out fine, If I manually type in .js in my main.js file. But that's not the solution.

var app_component_1 = require("./app.component.js");

Question Which setting should I change and which file that should resolve filename in the main.ts to filename.js

2

1 Answer 1

1

Finally, found the solution.. problem is with the dot in the file name , Issue is reported here too https://github.com/systemjs/systemjs/issues/756

I added the following setting in the systemjs.config file

packages: {

          '.': {
              defaultExtension: 'js'
          },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.