所以我在更新之前更新了nodejs。角度2没有得到错误,它工作正常,但现在更新node_modules它停止工作,我不知道错误将在哪里或如何解决它。
(index):29 Error: (SystemJS) Unexpected token <
SyntaxError: Unexpected token <
at eval (<anonymous>)
at Object.eval (http://localhost:3000/app/services/authentication.service.js:15:22)
at eval (http://localhost:3000/app/services/authentication.service.js:70:4)
at eval (http://localhost:3000/app/services/authentication.service.js:71:3)
Evaluating http://localhost:3000/node_modules/angular2-jwt/angular2-jwt.js
Evaluating http://localhost:3000/app/services/authentication.service.js
Evaluating http://localhost:3000/app/profile/profile.component.js
Evaluating http://localhost:3000/app/app.module.js
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js
at eval (<anonymous>)
at Object.eval (http://localhost:3000/app/services/authentication.service.js:15:22)
at eval (http://localhost:3000/app/services/authentication.service.js:70:4)
at eval (http://localhost:3000/app/services/authentication.service.js:71:3)
Evaluating http://localhost:3000/node_modules/angular2-jwt/angular2-jwt.js
Evaluating http://localhost:3000/app/services/authentication.service.js
Evaluating http://localhost:3000/app/profile/profile.component.js
Evaluating http://localhost:3000/app/app.module.js
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js
systemjs.config.js
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-jwt': 'node_modules/angular2-jwt/angular2-jwt.js',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
}
}
});
})(this);
的index.html
<html>
<head>
<title>Vietnam Films</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/ecommerce.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
<script src="//cdn.auth0.com/js/lock-9.0.min.js"></script>
</head>
<!-- 3. Display the application -->
<body>
<my-app></my-app>
<div class="loading">
<h1>Loading...</h1>
</div>
</body>
</html>
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
答案 0 :(得分:0)
开发工具是你的朋友。访问该页面时打开Chrome开发工具并检查网络选项卡。看看个别请求。我猜测http://localhost:3000/app/services/authentication.service.js
请求不会返回您希望的javascript,而是返回HTML错误页面。看看那个错误是什么,你会找到罪魁祸首。很可能它根本就没有找到文件(HTTP 404),但最好检查错误。
如果是404,请确保authentication.service.js正确地位于您要提供的app / services目录中。