在浏览器上加载应用程序时,我收到以下异常。请在下面找到配置文件和错误详细信息。
错误
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:59856/node_modules/@angular/core/index.js Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:17 Error: Error: XHR error (404 Not Found) loading http://localhost:59856/node_modules/@angular/core/index.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (https://npmcdn.com/zone.js@0.6.12?main=browser:769:30)
at ZoneDelegate.invokeTask (https://npmcdn.com/zone.js@0.6.12?main=browser:356:38)
at Zone.runTask (https://npmcdn.com/zone.js@0.6.12?main=browser:256:48)
at XMLHttpRequest.ZoneTask.invoke (https://npmcdn.com/zone.js@0.6.12?main=browser:423:34)
Error loading http://localhost:59856/node_modules/@angular/core/index.js as "@angular/core" from http://localhost:59856/app/main.js(anonymous function) @ localhost/:17
http://localhost:59856/node_modules/@angular/platform-browser-dynamic/index.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:59856/styles.css Failed to load resource: the server responded with a status of 404 (Not Found)
的package.json
{
"version": "1.0.0",
"name": "ngcorecontacts",
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"dependencies": {
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.2",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"tslint": "^3.7.4",
"typescript": "^1.8.10",
"typings": "^1.0.4"
},
"repository": {}
在Systemjs.Config.js
中 /**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
// map tells the System loader where to look for things
var map = {
'app': 'app',
'rxjs': 'node_modules/rxjs',
'@angular': 'node_modules/@angular'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/forms',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router'
];
// add package entries for angular packages in the form
// '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function (pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages
};
System.config(config);
})(this);
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
我在这里缺少什么?
答案 0 :(得分:3)
这是因为您正在从android:windowSoftInputMode="stateHidden|adjustResize"
加载您的应用程序,如此处所示:
appScripts
但是你的系统配置中指的是"outDir": "../wwwroot/appScripts/",
。
快速解决方法是从app
中删除outDir
并运行该应用程序。理想情况下,您应该使用@ angular-cli进行构建。看here
答案 1 :(得分:1)
我找到了答案。
您无法从wwwroot导入node_modules,但您必须将包中的包复制到wwwroot中的目标文件夹中,例如通过gulp,然后通过systemjs.config.js从那里导入它们。 使用Angular2-RC4的AspNet核心的工作解决方案,我已在github
上传为zip文件