我正在努力诊断此错误。它说它不能从我的main.js加载,但是我的main.js加载得很好……我想我缺少了app.set语句。或某种参考,我只是不知道什么。这是我的一些代码,我试图用Angular2作为前端创建一个MEAN堆栈。
主要
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);
});
我没有引用软件包或其他东西吗?提前感谢您的任何帮助。
编辑:这是错误...。
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 { }
我发现了问题,我的systemjs.config.js的路径错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句