Angular 2 dev environment wrong js file names

Essentially my angular 2 development settings are somehow wrong and I can’t make heads or tails as to how. This is what happens:

  1. I run npm start
  2. The script runs and compiles .js files out of the typescript files
  3. Browser is opened
  4. Nothing is shown

In the logs I see the following:

> 404 GET /app/app.component.ts.js

While the typescript compiler compiles files like app.component.js (notice the missing .ts)

So what’s going on? What is causing this and how to fix it?

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

I think that you don’t import modules the right way. You should use the following: import { AppComponent } from './app.component'; I guess that you do this: import { AppComponent } from './app.component.ts'; SystemJS will automatically append the js extension to module names if you use the following configuration for example: <script> System.config({ packages: { app: { format: 'register', defaultExtension: 'js' // <------------- } }, }); System.import('app/boot') // <------- No extension here as well .then(null, console.error.bind(console)); </script>

Jason
Guest

try this – import { AppComponent } from './app.component'; and System.config({ defaultJSExtensions: true, map: { rxjs: 'node_modules/rxjs' }, packages: { rxjs: { defaultExtension: 'js' } } }); System.import('app'); in your index.html