我有一个Angular 2项目,在我的机器和我的同事之间工作得很好,但是我的其他两个同事无法让项目运行。它们具有正确的Node,NPM和TypeScript版本,并且能够使Angular 2 Quickstart项目正常运行,但无论出于何种原因,当它们在我的项目上运行npm start
时,加载屏幕出现并且卡住了那里。浏览器控制台中没有错误,但是当它们运行npm start
时,它们会在node_module / systemjs / *内的.map文件上获得404。这些错误不会发生在我的机器上,事实上我没有看到任何证据表明我的机器在启动项目时甚至正在查找这些文件。为了摆脱这些错误消息,他说他删除了angular.min.js.map文件,但它没有解决应用程序未加载的问题。
我在这里完全不知所措。有谁知道可能导致这个问题的原因是什么?
这是我们的 package.json 文件:
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "^2.4.1",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/platform-server": "^2.4.1",
"@angular/router": "~3.4.0",
"angular-in-memory-web-api": "~0.2.4",
"angular2-google-maps": "^0.17.0",
"angular2-jwt": "^0.1.28",
"core-js": "^2.4.1",
"fullcalendar": "^3.1.0",
"moment": "^2.17.1",
"primeng": "^1.1.4",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
"devDependencies": {
"@types/googlemaps": "^3.26.0",
"@types/jasmine": "2.5.36",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"rollup": "^0.40.2",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1",
"tslint": "^3.15.1",
"typescript": "~2.0.10"
},
"repository": {}
}
这是我们的 systemjs.config 文件:
(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',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-jwt': 'npm:angular2-jwt/angular2-jwt.js',
'fullcalendar': 'npm:fullcalendar',
'primeng': 'npm:primeng',
'angular2-google-maps/core': 'npm:angular2-google-maps/core/core.umd.js' // For address autocomplete
},
// 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'
},
'angular2-jwt': {
defaultExtension: 'js'
},
primeng: {
defaultExtension: 'js'
}
}
});
})(this);
我们正在运行TypeScript 2.0,npm 3.10.10和节点6.9.4
答案 0 :(得分:0)
我发现了问题,它与我们的环境无关。最新版本的Angular 2路由器(3.4.8)存在问题,您可以在此处阅读:https://github.com/angular/angular/issues/14588
在Angular修复bug之前,解决方案是在3.4.7版本的路由器中锁定。对于遇到相同问题的任何人,请将package.json更改为:"@angular/router": "3.4.7",