Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Loading "@angular/platform-browser-dynamic" from http://localhost:3000/app/main.js

I am struggling diagnosing this error. It says it can't load from my main.js but my main.js is loading just fine... I think I am missing an app.set statement. or a reference of some sort, I just dont know what. here is a little bit of my code, I am trying to create a MEAN stack with Angular2 as my front end.

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);

server.ts

en///<reference path="../../typings/index.d.ts"/>

import express = require('express');
import path = require('path');

let port: number = process.env.port || 3000;
let app = express();


app.set('views', './src/client/views');
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);

app.use("/node_modules", express.static(path.resolve(__dirname, '../../node_modules')));
app.use("/app", express.static(path.resolve(__dirname, '../../src/client/app')));

app.use("/*.html", function (req, res) {
    res.render(req.params[0] + ".html");
});

app.get('/', function (req: express.Request, res: express.Response) {
           res.render('index.html')
})

let server = app.listen(port, function () {
let host = server.address().address;
let port = server.address().port;

console.log("Express app is listening on port: " + port);
});

am I not referencing the packages or something?? Thanks ahead of time for any help.

edit: here is the error....

Error loading http://localhost:3000/@angular/platform-browser-dynamic as "@angular/platform-browser-dynamic" from http://localhost:3000/app/main.js"

tscongif

{
 "compilerOptions": {
  "target": "es5",
  "module": "commonjs",
  "moduleResolution": "node",
  "sourceMap": true,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "removeComments": false,
  "noImplicitAny": false
 }
}

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

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

@NgModule({
  imports: [BrowserModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule { }

Also it might be worth knowing that I am following this tutorial here but I am using angular 2 rc.5

like image 784
Bean0341 Avatar asked Jul 13 '26 10:07

Bean0341


1 Answers

I figured out the issue, The path to my systemjs.config.js was wrong.

like image 103
Bean0341 Avatar answered Jul 15 '26 03:07

Bean0341



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!