无法加载@angular/platform浏览器动态
当应用程序加载时,我得到以下错误无法加载@angular/platform浏览器动态,angular,Angular,当应用程序加载时,我得到以下错误 http://localhost:49769/node_modules/@angular/platform-browser-dynamic/index.js Failed to load resource: the server responded with a status of 404 (Not Found) localhost/:21 Error: Error: XHR error (404 Not Found) loading http://localh
http://localhost:49769/node_modules/@angular/platform-browser-dynamic/index.js Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:21 Error: Error: XHR error (404 Not Found) loading http://localhost:49769/node_modules/@angular/platform-browser-dynamic/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:49769/node_modules/@angular/platform-browser-dynamic/index.js as "@angular/platform-browser-dynamic" from http://localhost:49769/app/main.js(anonymous function) @ localhost/:21
http://localhost:49769/node_modules/@angular/core/index.js Failed to load resource: the server responded with a status of 404 (Not Found)
请查找在我的项目中放置config和.ts文件的文件夹结构。请验证文件是否放置在正确的文件夹中
Package.json
{
"name": "Testing",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"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' },
'@angular/common': { defaultExtension: 'js', main: 'index.js' },
'@angular/compiler': { defaultExtension: 'js', main: 'index.js' },
'@angular/core': { defaultExtension: 'js', main: 'index.js' },
'@angular/http': { defaultExtension: 'js', main: 'index.js' },
'@angular/platform-browser': { defaultExtension: 'js', main: 'index.js' },
'@angular/platform-browser-dynamic': { defaultExtension: 'js', main: 'index.js' },
'@angular/router': { defaultExtension: 'js', main: 'index.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": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
为什么应用程序无法在node_模块下加载平台浏览器动态?我已验证指定文件夹下是否存在文件,但仍收到此错误
注意:尽管NPM/Dependencies文件夹显示“未安装”,但我可以展开该文件夹并注意到所有引用都已正确安装,但它仍然显示此错误/警告消息您无法从
wwwroot
导入节点\u模块
,但是您必须在wwwroot
的目标文件夹中复制捆绑包,例如通过gulp,然后通过systemjs.config.js
从那里导入它们。
wwwroot中的systemjs.config.js
位置正确
我建议您遵循以下几个示例:是否尝试重新启动IDE?尝试了多次,没有用…还有其他建议吗?尝试吹走整个node_modules dir并再次运行
npm install
。如果问题仍然存在,请在angular团队的github页面上提交错误报告。您的配置文件和package.json在我看来很好,因此不清楚发生了什么,如果不复制您的环境,就很难再现问题。请检查您的systemjs配置,特别注意bundles
folder尝试过炸毁整个节点模块,从Quickstart教程从头开始重新创建,但不起作用。在plunker中,它可以正常工作,当将相同的配置设置和其他组件放置在VisualStudioIDE中时,在运行应用程序时,我会遇到此错误。请从Github URL下载zip文件,