我正在尝试让我的Angular2(rc4)应用程序在我已构建的Node服务器上工作,但似乎失败了以下两个错误:
http://localhost:3000/node_modules/@angular/platform-browser-dynamic//bundles/platform-browser-dynamic.umd.js 404 (Not Found)
http://localhost:3000/node_modules/@angular/core//bundles/core.umd.js 404 (Not Found)
现在,我知道这些包是从我的systemjs.config.js文件中包含的,所以我已经在我的node_modules文件夹中检查了这个文件和脚本的位置,这一切都很好。文件存在那里,应该没有理由发生这种情况。
这让我觉得我的app.js NodeJS入口点文件存在问题,但我似乎无法看到问题。我在这里包含了该文件:
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var app = express();
app.use('/scripts', express.static(__dirname + '/node_modules/'));
app.use('/node_modules', express.static(__dirname + '/node_modules/'));
app.use('/templates', express.static(__dirname + '/views/templates/'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
module.exports = app;
任何人都可以看到为什么这些脚本没有被加载?这是我的index.html文件,用于衡量标准:
<html>
<head>
<base href="/">
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js"></script>
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="scripts/core-js/client/shim.min.js"></script>
<script src="scripts/zone.js/dist/zone.js"></script>
<script src="scripts/reflect-metadata/Reflect.js"></script>
<script src="scripts/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="javascripts/systemjs.config.js"></script>
<script>
System.config({
packages: {
javascripts: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('javascripts/app/main.js')
.then(null, console.error.bind(console));
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
由于